2012年1月18日 星期三

如何增進工程師效率–comma separated values (CSV)

CSV is a very convenient file format for data computing, processing, plotting, etc.

It can be imported or exported to/from excel. 

Ruby has a strong built-in support for CSV. 

Prior to Ruby 1.8.6, the built-in csv library in Ruby is csv, not very good nor efficient.

Fastcsv replace old csv after Ruby 1.8.7.  I recommend to use fastercsv with Ruby for csv processing.

For 1.8.6 to run fastercsv.  Either use rubygem to install: do “sudo gem install fastercsv”.

It does not work for me.   I download the gem from Rubyforge, then do sudo gem install fastercsv.

When use fastercsv, do “require ‘rubygems’,  then require ‘fastercsv’.

fastercsv has three different classes (format): csv, table, row

2012年1月1日 星期日

Emacs Mode for Engineering

Emacs and Vi are probably the most popular general purpose editor for Unix, Linux, etc.

Richard Stallman visited Stanford AI lab and was inspired by the “E” editor.  He returned MIT and refined the original TECO editor.  The E-"MACS”  represents  Editing MACroS.  Vi was written by Bill Joy in 1976.  It stands for VIsual mode of a line editor and was released as part of first BSD Unix in 1978.  

本文 focus 在 emacs 的 mode 設定。主要包含下列應用:

Programming and scripting language

C/C++/Java : .c/.cpp/.java – supported by default

Perl, Ruby, Python, Tcl:  .pl/.rb/.py/.tcl  – except for Ruby, others are supported by default

Matlab: .m

Linux Tool and shell script (linux only)

Makefile – supported by default

tcsh/csh/bash : .cshrc/.tcshrc/.bashrc – supported by default

CAD

Verilog: .v

Skill (Cadence Lisp): .il/.ocn/.cdf

Spice and spectre netlist: .cdl/.sp/.cir/.ckt

 

Linux Emacs Setting

1. In Linux, default emacs mode setting is put in /usr/share/emacs/site-lisp/ directory.  For example, python-mode.elc is stored in it.   -> Need a supersuer account to do this! Easier to use step 2.

2. User local mode setting is in ~/.emacs.d/ directory.  Therefore, I download matlab.el from MathWork; ruby mode, verilog-mode.el, skillMode.el, and spice-mode.el.  -> Put mode files here!!!

3. ~/.emacs specifies mode files to be loaded.  It needs to be modified to support these modes.   The key commands in .emacs are:

(autoload 'matlab-mode "matlab" "Enter Matlab mode." t)
(setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist))

autoload requests to load the “matlab.el” file from load-path.   auto-mode-alist applies matlab-mode setting to files endding with “.m”.

Windows Emacs Setting

1. General emacs setting: windows does not support emacs by default.  I need to download the emacs package from internet.  I installed emacs in c:\emacs\emacs-23.1\.

2. The default emacs mode setting is put in c:\emacs\emacs-23.1\site-lisp\.  -> Put mode files here!!!

3. The user local mode setting is in $HOME\.emacs.d\ directory.  I set environment (user) variable HOME as c:\emacs\.  The setting is in computer->advanced setting->environment variable->USER->HOME.  -> Don’t put mode files in this directory since it cannot find in the load-path.  Maybe need to specify the full path of load-path.

4. The initial file (similar to .emacs, cannot start with . in Windows) is put in $HOME\.emacs.d\init.el in Emacs 22 or later. 

2. Desktop UI setting: to make sure mouse right key can bring up emacs

 

Where to get mode file

Python-mode.el:   https://launchpad.net/python-mode

Ruby-mode.el: svn co http://svn.ruby-lang.org/repos/ruby/trunk/misc ruby-mode

Matlab.el: http://sourceforge.net/projects/matlab-emacs/

Verilog-mode.el: http://www.veripool.org/wiki/verilog-mode

SkillMode.el: TBA

Spice-mode.el:  http://spice-mode.4t.com/

追蹤者