算法训练

刘先毅提到 现在的成绩与最初选拔时有很大的进步,练习是有意义的。
1.从有语法错语,无法调通程序到可以AC题目;
2.对提高工程能力有作用;
3.对其他科目实验有作用。关怡然提到 应该如何训练。
关健问题不在于理解与否,而在于速度。
1.反复做同一道典型题,直至可以在规定时间内完成某个算法。
  如在半小时写出最小生成树算法。
2.对比
  1)大量语法错误,需要实验语法;
  2)不知道某功能应用何种函数实现,函数的参数表,需要实验函数的执行效果(作用);
  3)不知道经典算法,需要现场考虑算法;
  4)不能熟练写出经典算法,需要现场调试。

Byte array String in C# .Net

Byte myBytes1[]   =   myMemoryStream.ToArray();
String str   =   System.Text.Encoding.Default.GetString( myBytes1  );
Byte myBytes2[]=System.Text.Encoding.Default.GetBytes( str )   ;

Byte   myBytes1[]   =   myMemoryStream.ToArray   ();
String   str   =   (new   UnicodeEncoding()).GetString( myBytes1 );
Byte   myBytes2[]   =   (new   UnicodeEncoding()).GetBytes( str )   ;

Windows中的计时器(SetTimer和CreateWaitableTimer)

Windows中的计时器(SetTimer和CreateWaitableTimer)   
Timers (SetTimer and CreateWaitableTimer) in Windows
       
1.SetTimer
下面的例子创建了一个计时器(不与窗口相关联),该计时器过程函数建了20个消息框。
The following example creates a timer (that is not attached to a window) whose Timer Procedure creates 20 Message Boxes

#include <windows.h>

class foo_class {
  static int counter;
public:
  //static函数,相当于全局
  static void  __stdcall timer_proc(HWND,unsigned int, unsigned int, unsigned long) {
    if (counter++ < 20)
      MessageBox(0,"Hello","MessageBox",0);
    else
      PostQuitMessage(0);
  }
};

int foo_class::counter=0;

WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) {

//第1个参数,MSDN中指出如果置为NULL,即0,不与窗口相关联。
//If this parameter is NULL, no window is associated with the timer and the nIDEvent parameter is ignored.
//第2个参数会被忽略
//第3个参数,300毫秒触发一次
//第4个参数,触发时由函数foo_class::timer_proc响应
int iTimerID = SetTimer(0, 0, 300, foo_class::timer_proc);
  MSG m;
//这是消息循环
  while (GetMessage(&m,0,0,0)) {
    TranslateMessage(&m);
    DispatchMessage(&m);

   }
  return 1;
}

2.CreateWaitableTimer
这个例子演示如何在windows中使用计时器。
计时器被设计为(1)在第1次调用CreateWaitableTimer后2秒触发,(2)此后每3/4秒触发一次。
#define _WIN32_WINNT 0x0400

#include <windows.h>
#include <process.h>
#include <stdio.h>

unsigned __stdcall TF(void* arg) {
  HANDLE timer=(HANDLE) arg;

  while (1) {
    //此处,进程间通信的接收方
    //timer是命名的,因此进程间或线程间没有区别
    WaitForSingleObject(timer,INFINITE);
    printf(".");
  }

}

int main(int argc, char* argv[]) {
  //创建,命名为0,也可以是LPCTSTR,字符串
  //其他进程可以通过OpenWaitableTimer获得此timer的句柄,并对之进行SetWaitableTimer
  HANDLE timer = CreateWaitableTimer(
    0,
    false, // false=>will be automatically reset
    0);    // name

  LARGE_INTEGER li;

  const int unitsPerSecond=10*1000*1000; // 100 nano seconds

  // Set the event the first time 2 seconds
  // after calling SetWaitableTimer
  //2秒
  li.QuadPart=-(2*unitsPerSecond);
  //通过句柄设置timer
  SetWaitableTimer(
    timer,
    &li,
    750,   // Set the event every 750 milli Seconds
    0,
    0,
    false);
  //用TF函数启动worker线程
  _beginthreadex(0,0,TF,(void*) timer,0,0);

  // Wait forever,
  while (1) ;

  return 0;
}

参考:
1.[http://www.adp-gmbh.ch/win/misc/timer.html ]2.[http://support.microsoft.com/kb/184796],中文的

MIT开放课程 Structure and Interpretation of Computer Programs video下载

MIT开放课程 Structure and Interpretation of Computer Programs video下载:

  教材Structure And Interpretation Of Computer Programs – Mit Press,
  使用Scheme语言
  有免费工具MIT Scheme,
  在[ http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-001Spring-2005/Tools/detail/Guide-to-MIT-Scheme.htm]
  支持Windows和Linux。

视频下载:
1.flash或mp4
MIT OCW – 6.001 Structure and Interpretation of Computer Programs (1986)
[http://www.archive.org/details/MIT_Structure_of_Computer_Programs_1986]或
[ http://ia350602.us.archive.org/3/items/MIT_Structure_of_Computer_Programs_1986/]

2.avi(Divx)或mpg, bit torrent supported
[http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/ ]

  感谢刘典先生推荐[Structure And Interpretation Of Computer Programs – Mit Press],
他告诉我这本书能帮助确定”机制与策略”的分离。
  感谢李粲先生同意刘典先生推荐这本书,李粲先生与刘典先生一同指出《Unix程序设计艺术》中的”机制与策略”正符合我所说的原则。
  感谢不记得什么时间谁请的烤牛肉,它让我们的交流很畅快。

Total Commander – Addons分类

Total Commander – Addons:
“Plugins

Packer plugins
Packer plugins offer additional pack formats inside of Total Commander, or allow access to special file formats like CD-ROM images, or list files.
File system plugins
File system plugins allow access to whole file systems via the Network Neighborhood, e.g. to a PocketPC device or a Linux file partition.
Lister Plugins
Lister-Plugins allow to show specific file types via F3, e.g. program code with syntax highlighting.
Content Plugins
Content plugins allow to extract specific data from files, like mp3 tags or photo information (e.g. exposure time). This data can be displayed in file lists, or used in the search and multi-rename functions.”

不使用backtick处理参数

  backtick, the grave accent ( ` ) is a diacritic mark [wikipeida]。
  如果使用backtick,那么在unix shell中,可以方便地用’cat ini_file.ini’把配置文件中的内容取出,对于配置文件只有一行的情况。如果配置文件有多行,也可以使用shell工具取出某行的数据。
  放弃backtick方案。 仍使用GUI部分从配置文件读入参数,再作为批处理的命令行参数。配置文件准备使用多个,每个参数一个文件,方便使用fstream读入,避免使用windows api。
放弃backtick方案的原因如下。
  需要重写所用已用批处理实现的场景 ;

已经与袁福宇一起测试了可行性。
1.在shell中的使用方法。不是原文引用,可能有错。
  >test.exe -para `cat device_name.txt`
等同于执行
  >test.exe -para .EmeterDevice0
其中,'.EmeterDevice0'是device_name.txt的内容。
需要注意当前目录、配置文件目录。

2.在shell之外,由GUI调用的方法。
----引用开始
d:msys1.0bin>sh
sh-2.04$ exit
exit

d:msys1.0bin>sh test.sh
ok

d:msys1.0bin>cat test.sh
echo ok
d:msys1.0bin>
----引用结束

备忘,免得哪天又把这个方案想起来,然后再花上大半天否定它。

用键盘断开U盘的几个方法(转载)

发信人: qjchen (飞马), 信区: TotalCommander
标 题: 用键盘断开U盘的几个方法,感谢younggift兄
发信站: 水木社区 (Thu Apr 26 06:57:38 2007), 站内用usb disks插件好久了,好像用的是那个06.8.28的版本,却一直忘记了在哪里下载了,今天总算知道了,非常感谢younggift兄。以前写过如下一段,发文灌水一下。
用键盘断开U盘的几个方法
不少电脑爱好者都喜欢采用键盘来控制电脑。但是要断开U盘的时候,一般情况下需要用鼠标去点击系统右下角的图标点击”安全删除硬件”图标来安全删除硬件。有没有什么方法可以用键盘来断开U盘连接呢?经过研究及搜索,得到如下的几个解决方法。
第一个方法:命令调出法
用WIN +R调出运行窗口,输入如下中括号内的文字,不包括中括号[“C:WINDOWSsystem32rundll32.exe”
shell32.dll,Control_RunDLL
hotplug.dll],注意,C:WINDOWS需要按照你的操作系统改成相应的名称。那么就会跳出常见的安全删除硬件的窗口,按Alt+s,假如只有一个U盘的话,再按一次回车就可以了。这段文字在再次调用WIN+R时一般就会存在列表中了。操作起来其实很快。
对于喜欢键盘操作的朋友, hoekey是一个绝好的软件。下载安装后,在Hoekey的安装目录中找到hoekey.ini文件,在最后加上如下中括号内的文字,不包括中括号:
[F9=Run|”C:WINDOWSsystem32rundll32.exe” shell32.dll,Control_RunDLL
hotplug.dll; F9: close u
disk],以后按F9就可以出现安全删除硬件的窗口了。假如利用可定义键盘、鼠标动作的Autohotkey脚本软件应可更快。第二个方法:利用Total Commander的Usb disks插件
Total commander是一个著名的文件管理程序,此处不赘述。
此时,下载一个TC的Wfx插件――Usb disks,此插件应该是水木younggift的作品,具体下载地址可见后文。
进入TC中的Configuration(配置)-Option(选项)-Plugins(插件)-Wfx,在Wfx旁边的configure里面添加这个
usb disks即可。重启tc让之生效。假如采用鼠标时,在TC里面点击网络邻居的磁盘图标,可以看到有一个叫Usb
disks的目录,进入可以看到相应的usb设备。比如我电脑中就有Microsoft USB Wheel Mouse
Optical――Usb鼠标,还有Usb Mass Storage的――就是U盘。此时,对Usb Mass
Storage按del键,就断开了U盘的连接了,试试看,还可以断开鼠标的。
那么,如何才能用键盘进入这个Usb Disk的目录呢?可以借助TC中的start(开始菜单)菜单,start(开始)-change
start menu(改变开始菜单)-add items(添加项目),给个名字比如叫exit U,在窗口下方的command命令行中键入cd
USB Disks,再在Shortcut
key中定义一个如ctrl+alt+F3的快捷方式,那么以后就可以按Ctrl+Alt+F3键进入这个Usb
Disk的界面,按Del键退出U盘了。第三个方法:借助Unplug.exe软件
这个软件叫unplug.exe, 是专门退出U盘的,解压到一个目录中,如D:program filesunplug,接着,打开记事本键入如下内容
@echo off
cd D:program filesunplug
unplug J:
unplug K:
注意,第二行中,地址改为相应的unplug地址,第三第四行中,是对应机器的U盘盘符,可以是多个。存这个文本文件为一个批处理文件,如removej.bat。
接下来就可以按win+R来运行这个批处理文件了,也可以类似上文一般,用hoekey,定义一个[F10=Run|”d:program
filesunplugremovej.bat”],不包括中括号。以后,按一个F10键就可以一次性关闭几个U盘了。
不记得是不是在DRL,有位大哥说要配合UNLOCK一起用会更好,有空试试。可能你会觉得,不就是退出U盘嘛,用得着大惊小怪搞得这么复杂么,但事情嘛,多个解决方法总不是坏处,是吧。
以上软件的下载地址。
Totalcmd: http://ghisler.fileburst.com/655a/tcmd655a.exe
TC的Usb Disks插件: http://www.newsmth.net/bbscon.php?bid=837&id=27274
Hoekey: http://www.bcheck.net/apps/HoeKey113Inst.exe
Unplug.exe: http://hp.vector.co.jp/authors/VA009794/UPLG0098.zip本文也记在这里:http://younggift.net/2007/04/26/u/
–结构分析、CAD Autolisp技术、软件使用技巧http://chenqj.blogspot.com
※ 修改:・qjchen 于 Apr 26 07:01:57 修改本文・[FROM: 59.41.189.*]※ 来源:・水木社区 http://newsmth.net・[FROM: 59.41.189.*]newsmth上的补充:
1.用键盘移动焦点,向鼠标一样删除U盘
  Ctrl-Esc,Esc,Shift-Tab,Shift-Tab,Left or Right,Space,Up,Enter
2.我比较喜欢用前面有人贴过的那个deveject.exe的程序
3.直接拔
  win默认就是可以直接拔的
4.把焦点移到SysTray,直接Win+B

Emacs用于编程环境

  • download
  • install
    • Emacs
    • djgpp
  • IDE
    • auto indent
      • Language (auto-indent) Modes
        • c++-mode
    • 变量、函数、类的 定义,cross reference
      • etags
    • beautifier
      • astyle
      • cc-mode
        • 选择文本块,ESC C-,M-X c-set-style,可以设置不同的缩进风格
    • symtax highlight
      • font-lock-mode
    • Include File Searching
      • FFAP mode
      • dired mode
    • 后缀自动识别
      • auto-mode-alist entry
      • font-lock-auto-mode-list
    • refactoring
      • Xrefactory
        • 官方8天试用
    • 智能补齐
      • CEDET
      • Sematic
    • 括号匹配
      • C-M-n和C-M-p则可以将光标定位在两个匹配的括号上
    • debug
      • dbg
      • dbx
    • 自动定位到语法错误的行
      • 内置
    • compiler
      • 内置
        • make -k
      • g++ hello.cpp -o hello.exe
    • 调用stack
      • Ebrowse is a parser that generates browsable tree files from C++ source code. It is part of the emacs release starting with version 21.2. etags, 最简单 ecb(emacs code browser),最复杂 cscope, 位于中间的是
    • 代码折叠
      • foldout(内置)
      • folding-mode
      • fold-mode
      • hs-minor-mode
    • 模板
      • http://emacs-template.sourceforge.net
      • auto-insert(内置autoinsert)
    • IDE plugin
      • ELSE(Emacs Language Sensitive Editor)
      • JDE
      • VIP
    • block comment
      • comment-region
      • cc-mode
        • comment-region
        • Multi-Line Comments
    • MISC
      • 看函数体时,函数头能否常驻屏幕顶端
        • 装了 semantic 后, `M-x global-semantic-stickyfunc-mode’
      • 工程管理
        • cedet
  • sh
    • GNU Bash
    • win-bash
    • UWIN(at&t)
  • unix utilities
    • ~ gnuwin32
      • ls
      • grep
      • cat
    • http://unxutils.sourceforge.net/
    • msys @ mingw32
  • compiler
    • g++
      • mingw32
      • Cygwin (GNU+Cygnus+Windows)
  • documentation
    • doxygen

excel在项目中

备忘。
1.利用 XY散点图 检验数据的线性
  曾经用在ECC硬件调试时,检验电压的映射公式。
2.利用 公式求值 检验公式的有效范围/函数图形
  曾经用于检验SPR的 电机与角度关系。
3.利用透视表(pivot table) 汇总、分类、对比
4.选择图表类型时参考《用图表来说话》中的5种类型。