Showing posts with label misc. Show all posts
Showing posts with label misc. Show all posts

Sunday, August 11, 2013

Bochs notes

Installation on Ubuntu:

sudo apt-get install bochs
sudo apt-get install bochs-x
sudo apt-get install bochs-sdl
sudo apt-get install bochs-term

BIOS ROM image is installed by package bochsbios to.
  -  /usr/share/bochs/BIOS-qemu-latest
  -  /usr/share/bochs/BIOS-bochs-legacy
  -  /usr/share/bochs/BIOS-bochs-latest

By default, /etc/bochs-init/bochsrc is NOT loaded.

To change display library to SDL: display_library: sdl

Make floppy image: dd if=Boot1.bin of=floppy-drive/floppy.img

If you use term, to quit simulation, run command "kill -HUP <process_id>" in a separate console

Wednesday, June 26, 2013

shell PS1 terminal escape sequence in linux

If you've seen string like this "\[\e[1;33m\]" in someone's PS1 (bash prompt) value, you may be curious about what it means. Or you may be using it, but not really know what it means (e.g. just copied and pasted from another bash config file). The format is weird. Isn't it?

PS1 bash prompt

run "man bash", search for PROMPTING, you will see that

  1. \[  begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
  2. \]  end a sequence of non-printing characters

You may wonder what "terminal control sequence" is. Generally "terminal control sequence" controls how the data and/or presentation maintained by terminal will be changed (e.g. move cursor, change color, delete line).

ECMA-48

The "terminal control sequence" is defined in ECMA-48 spec [1]. Here I will be focused on only one commonly used terminal control sequence called SGR (the detail is on page 75 of the pdf file, or page 61 of the spec content). SGR controls many graphics aspect of terminal display.

SGR - Select Graphic Rendition. You can think it as just a function which takes some parameters. We need to represent/serialize it so that it can be transferred and interpreted by terminal, etc. Its representation in the spec is "CSI Ps... 06/13". I break it down in the follow table:

Parts

full name

ascii code (hex)

breakdown of example "\e[1;33m"

CSI Control Sequence Introducer For 8-bit mode: 0x9b
For 7-bit mode: 0x1b5b("\e[")
"\e[" is CSI
Ps… parameters each control function can have one or more parameters. "1;33" are two parameters
    SGR can have multiple parameters. Each parameter is an integer represented in decimal notation. 1 means bold; and 33 means yellow foreground color
    Parameters are separated by 0x3b (';')  
06/13 control function SGR 0x6d ('m') "m"

You may wonder why parameter 33 means yellow and parameter 1 means bold. You cannot feed arbitrary parameter values to SGR. The allowed parameter values are (copied from [1]) shown below. The items marked as bold text are the commonly used parameters.

0 default rendition (implementation-defined), cancels the effect of any preceding occurrence of SGR in
the data stream regardless of the  setting of the GRAPHIC RENDITION COMBINATION MODE
(GRCM)
1  bold or increased intensity
2  faint, decreased intensity or second colour
3 italicized
4 singly underlined

5  slowly blinking (less then 150 per minute)
6  rapidly blinking (150 per minute or more)
7 negative image
8 concealed characters
9  crossed-out (characters still legible but marked as to be deleted)
10  primary (default) font
11  first alternative font
12  second alternative font
13  third alternative font
14  fourth alternative font
15  fifth alternative font
16  sixth alternative font
17  seventh alternative font
18  eighth alternative font
19  ninth alternative font
20 Fraktur (Gothic)
21 doubly underlined
22  normal colour or normal intensity (neither bold nor faint)
23  not italicized, not fraktur
24  not underlined (neither singly nor doubly)
25  steady (not blinking)
26  (reserved for proportional spacing as specified in CCITT Recommendation T.61)
27 positive image
28 revealed characters 
29  not crossed out
30 black display
31 red display
32 green display
33 yellow display
34 blue display
35 magenta display
36 cyan display
37 white display

38  (reserved for future standardization;  intended  for setting character foreground colour as specified in
ISO 8613-6 [CCITT Recommendation T.416])
39  default display colour (implementation-defined)
40 black background
41 red background
42 green background
43 yellow background
44 blue background
45 magenta background
46 cyan background
47 white background
48  (reserved for future standardization; intended for setting character background colour as specified in
ISO 8613-6 [CCITT Recommendation T.416])
49  default background colour (implementation-defined)
50  (reserved for cancelling the effect of the rendering aspect established by parameter value 26)
51 framed
52 encircled
53 overlined
54  not framed, not encircled
55 not overlined
56  (reserved for future standardization)
57  (reserved for future standardization)
58  (reserved for future standardization)
59  (reserved for future standardization)
60  ideogram underline or right side line 
61  ideogram double underline or double line on the right side 
62  ideogram overline or left side line
63  ideogram double overline or double line on the left side
64  ideogram stress marking
65  cancels the effect of the rendition aspects established by parameter values 60 to 64

More

PS1 is only one of the places where you can specify terminal control sequence. Many other programs also accept it. For example, in my .inputrc (config for readline), I have config like:

"\e[1~": beginning-of-line               # control sequence ending with '~' is for private use.
"\e[4~": end-of-line                        # In other words, we hope these control sequences are sent to terminal
                                                    # when we try to move cursor to the beginning/end of the line
                                                    # (e.g. press home/end key), and terminal can understand them

"\e[5C": forward-word                     # ECMA-48 section 8.3.20 CUF - cursor right
"\e[5D": backward-word                  # ECMA-48 section 8.3.18 CUB - cursor left
"\e[1;5C": forward-word                  # Other config is not specified in the standard.
"\e[1;5D": backward-word               # They may be extensions or just non standard compliant implementation
"\e\e[C": forward-word
"\e\e[D": backward-word
"\e[1;\e[C": forward-word
"\e[1;\e[D": backward-word

I added comments into the config so you can easily know the references.
If you are not sure what key sequence is sent when you press home/end key on your keyboard, run command "cat -v", and press the key. For me, cat shows "^[[1~" when I press home key. You can replace "^[" with "\e" and get the terminal control sequence.

References:

[1] http://www.ecma-international.org/publications/standards/Ecma-048.htm

Tuesday, April 16, 2013

File Associations in Windows Regsitry

See [1] for the description of HKLM, HKCU, and HKCR. According to [2], HKCR provides a merged view of HKCU and HKLM. For ProgID, see [3]. For file extension, see [5].

File extensions config examples (see [7] for valid keys/entries):

for .rar:

  • HKLM/SOFTWARE/Classes/.rar has a key "(Default)" with ProgID "7-Zip.rar"
  • HKCU/Software/Microsoft/Windows/CurrentVersion/Explorer/FileExts/.rar
    • child: OpenWithProgids has a key named "7-Zip.rar" (appear in "open with" menu)
for .txt:
  • HKLM/SOFTWARE/Classes/.txt (apply to all users)
    • keys: (Default)=txtfile; Content Type=text/plain (txtfile is ProgID)
    • child: OpenWithProgids (appear in "open with" menu)
    • child: ShellNew
  • HKCU/SOFTWARE/Classes/.txt (apply to the interactive user)
    • Does not exist in my case
  • HKCU/Software/Microsoft/Windows/CurrentVersion/Explorer/FileExts/.txt (apply to the interactive user)
    • child: OpenWithProgids has a ProgID "txtfile"
    • child: UserChoice has a key named "Progid" with value "Applications/notepad++.exe" (!important)

Applications with ProgID:

  • HKLM/SOFTWARE/Classes/7-Zip.rar/shell/open/command (7-Zip.rar is ProgID)
  • HKLM/SOFTWARE/Classes/txtfile/shell/open/command: the value of "(Default)" is the command used to open files.

How a file extension (e.g. .txt) is mapped to a file type?

  • "UserChoice" takes the first precedence. If it is not set, key "(Default)" stores the ProgID which can be found under [HKCU|HKLM}/SOFTWARE/Classes/.

For gvim.exe, you should have HKLM/SOFTWARE/Classes/Applications/gvim.exe/shell:

  • edit/command[(Default)] = command
  • open/command[(Default)] = command
    Notes: "gvim.exe" is ProgID, see [3] for more detail.

How to change the default app when a file is double-clicked? (Take .c as an example)

  • Solution 1 (use entries for Explorer)
    1. For HKCU/Software/Microsoft/Windows/CurrentVersion/Explorer/FileExts/.c/UserChoice, set the value of key "UserChoice" to "Applications/gvim.exe".
    2. For HKLM/SOFTWARE/Classes/Applications/gvim.exe/shell/edit/command, set the value of key "(Default)" to '"C:\Program Files (x86)\Vim\vim73\gvim.exe" -p --remote-tab-silent "%1" "%*"'
    3. Open "Control Panel\Programs\Default Programs\Set Associations", you will see .txt has been associated with gvim.exe.
  • Solution 2
    UserChoice should not be set in this solution (you can delete it first).
    1. make sure HKLM/SOFTWARE/Classes/.c has the key "(Default)" set to "cfile".
    2. For HKLM/SOFTWARE/Classes/cfile/shell/open/command, set "(Default)" to the gvim command above.

References

[1] http://msdn.microsoft.com/en-us/library/windows/desktop/ms724475%28v=vs.85%29.aspx
[2] http://msdn.microsoft.com/en-us/library/windows/desktop/ms724498%28v=vs.85%29.aspx
[3] http://msdn.microsoft.com/en-us/library/windows/desktop/dd542719%28v=vs.85%29.aspx
[4] http://msdn.microsoft.com/en-us/library/windows/desktop/ms690440%28v=vs.85%29.aspx
[5] http://msdn.microsoft.com/en-us/library/windows/desktop/ms678415%28v=vs.85%29.aspx
[6] http://msdn.microsoft.com/en-us/library/windows/desktop/hh127445%28v=vs.85%29.aspx
[7] http://msdn.microsoft.com/en-us/library/windows/desktop/cc144148%28v=vs.85%29.aspx#fa_optional_keys_attributes

Sample reg file

Be careful, it will overwrite the current value!!!
============================================

Windows Registry Editor Version 5.00 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.c] 
@="cfile" 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\cfile\shell\open\command] 
@="\"C:\\Program Files (x86)\\Vim\\vim73\\gvim.exe\" -p --remote-tab-silent \"%1\" \"%*\"" 
============================================
Note: the value must be a string put in double quotations!
  

Friday, September 14, 2012

Jabberd2 and OpenFire notes

Resources:
http://www.24100.net/2009/11/federate-google-wave-sandbox-with-your-own-fedone-server/

If you have a pkcs12 that contains your private key and certificate chain, use following command to convert it to pem:

openssl pkcs12 -in startssl.p12 -out startssl.pem –nodes

Maybe you need to manually adjust order of certificates in the generated pem file. You client cert should appear first, then certs from intermediate CAs, and root CA cert.

Read comments in file http://codex.xiaoka.com/svn/jabberd2/trunk/etc/c2s.xml.dist.in

<id register-enable='true'
    require-starttls='true'
    pemfile='/home/gerald/ongoing/jabberd2/startssl.pem'>129-79-49-197.dhcp-bl.indiana.edu</id>

Don’t put it this way for readability:

<id register-enable='true'
    require-starttls='true'
    pemfile='/home/gerald/ongoing/jabberd2/startssl.pem'>
129-79-49-197.dhcp-bl.indiana.edu</id>

You will get “Host Unknown” error :-(

FedOne

router.xml
local –> secret

run-config.sh
XMPP_SERVER_PORT=5347

sm.xml: sm->id

c2s.xml: c2s->local –>id

Certificate for you domain

openssl genrsa 2048 | openssl pkcs8 -topk8 -nocrypt -out wave1.example.com.key
openssl req -new -nodes -sha1 -days 365 -key wave1.example.com.key -out wave1.example.com.csr
Note: Common Name (eg, YOUR name) []: wave1.wave.zhenhua.info

DNS

SRV

Settting
_xmpp-server._tcp.wave1.example.com               wave1.example.com 5269
_xmpp-server._tcp.wave.wave1.example.com      wave1.example.com 5269

Priority and weight are not so important in our SRV settings.

Testing
dig +short -t SRV _xmpp-server._tcp.wave1.example.com
dig +short -t SRV _xmpp-server._tcp.wave.wave1.example.com

A

wave1.example.com    your_server_ip_address

FedOne server config

WAVE_SERVER_DOMAIN_NAME=wave1.example.com     # not wave.wave1.example.com

XMPP_SERVER_PING=initech-corp.com

Use ./check-certificates.sh to check your certificate settings.

 

Hostname used set in OpenFire and FedOne server should match (wave1.example.com in our example).

edit /etc/openfire/openfire.xml, change <setup>true</setup> to <setup>false</setup>. restart the server.

Server Manager –> Server Information, section “Server Properties”:
Server Name: wave1.example.com

OpenFire

Add a user named “username”. Your users will have accounts like username@wave1.example.com

Test

Open client console: ./run-client-console.sh username

type /new, /open 0, /add your_wavesandbox_account, then type a message. You should see the message in your wavesandbox page. There is delay (for me about 1 minute).

In google wave sandbox, add user@wave1.example.com to your address book

windows migration notes

Bakcup
Following is the default profile/configuration file locations for some programs. It may vary because of your customized setting during installation.

  • Messenger
    c:\Users\gerald\Documents\My Received Files\jenvor381158107\
  • WLW
    c:\Users\gerald\Documents\My Weblog Posts\
    c:\Users\gerald\AppData\Roaming\Windows Live Writer\
  • Skype
    c:\Users\gerald\AppData\Roaming\Skype\
  • Filezilla
    c:\Users\gerald\AppData\Roaming\FileZilla\
  • Totalcmd
    c:\Users\gerald\AppData\Roaming\GHISLER\
    Change file wincmd.ini: to add a section for your resolution (like [1024 x 768])
  • Firefox
    c:\Users\gerald\AppData\Roaming\Mozilla\
  • SecureCRT
    c:\Users\gerald\AppData\Roaming\VanDyke\Config\
  • Outlook
    pst files: c:\Users\gerald\AppData\Local\Microsoft\Outlook\
    Accounts: go to registry Current_User/Software/Microsoft/WindowsNT/Messaging Sub Systems/Outlook/Profile, export and import it
  • FileZilla server
    The installation directory. cert

Sunday, February 19, 2012

implement readLine using read

http://www.mitbbs.com/article_t/JobHunting/32042617.html
char *readLine() {
    int bufSize = 1024;
    static char *buf = malloc(sizeof(char) * (1 + bufSize));
    static int bytesAfterNewLine = 0;   // number of bytes left from last call
    static int lastpos = 0;             // where the leftover starts

    int totalBytes = 0; // total number of bytes in the array
    int foundLineBreak = 0;

    if (bytesAfterNewLine != 0) {
        memmove(buf, buf + lastpos, bytesAfterNewLine);
        totalBytes = bytesAfterNewLine;
        lastpos = 0;
    }

    while (true) {
        for (; lastpos < totalBytes; ++lastpos) {
            if (buf[lastpos] == '\n') {
                buf[lastpos] == '\0';
                bytesAfterNewLine = totalBytes - lastpos - 1;
                foundLineBreak = 1;
                lastpos = (last + 1) % bufSize;
                break;
            }
        }
        if (foundLineBreak) break;

        if (bufSize == totalBytes) {
            bufSize *= 2;
            buf = realloc(buf, bufSize + 1);
        }

        int bytes = 0;
        while (true) {
            bytes = read(buf + totalBytes, bufSize - totalBytes);
            if (bytes != 0) break;
        }

        if (bytes == -1) {
            buf[totalBytes] = '\0';
            break;
        }

        totalBytes += bytes;
    }

    if (totalBytes == 0 && foundLineBreak == 0) {
        return NULL:
    } else {
        return buf;
    }
}

Saturday, February 18, 2012

How to delete the blank page after a table in Microsoft Word

This stupid and simple problem has been bugging me for ages!!! There is a simple workaround for me.
Select the blank paragraph, go to Font dialog, in tab "Font", select "Hidden", then the annoying blank page just disappears.

Note: if you turn on "Show paragraph marks and other hidden formatting symbols", the hidden text will be shown.

Monday, December 12, 2011

RabbIT

Enable filter rabbit.filter.ReverseProxy, by adding it to the front of httpinfilters value.
Configure values for sector rabbit.filter.ReverseProxy.
httpinfilters=rabbit.filter.ReverseProxy,rabbit.filter.HttpBaseFilter,rabbit.filter.DontFilterFilter,rabbit.filter.BlockFilter,rabbit.filter.RevalidateFilter
......
[rabbit.filter.ReverseProxy]
# This filter is not enabled by default, add it to httpinfilters if you want it.
# This Filter makes rabbit work as an accellerator for one web site.
# Change requests
transformMatch=^/(.*)
transformTo=http://<target_host>:
<port>/$1
# Deny proxy requests, you probably want this.
# deny=^http(s?)://.*
deny=
# If we want to allow admin access.
allowMeta=true
Run RabbIT:
java -jar jars/rabbit4.jar -f conf/rabbit.conf
Resource: http://www.khelekore.org/rabbit/

Tuesday, September 13, 2011

Vdbench notes

Two types of supported testings.  Following table shows the configuration groups for these testings.

Storage device testing File system testing
General - optional General - optional
Host Definition(HD) - optional Host Definition (HD) - optional
Storage Definition(SD) File System Definition (FSD)
Workload Definition(WD) File System Workload Definition(FSWD)
Run Definition (RD) Run Definition (RD)

Different configuration groups may be specified in one single file or multiple files (use multiple -f options to specify all of them).

Comments: a line starting with '/', '#', or '*' is a comment.
Continuation: end a line with a comma plus a whitespace.

Output file
-o dirname+   # if dirname has existed, use dirname001.
-o dirname.tod    # the directory name will be dirname.yymmdd.hhmmss

General parameters

Vdbench_global_param

Host definition

Vdbench_host_def_param

Storage definition

Vdbench_storage_def_param

Workload definition

Vdbench_workload_def

Run definition

Vdbench_run_def_param

File System Definition

Vdbench_filesystem_def_param

File System Workload Definition

Vdbench_filesystem_workload_def_param

Run definition for file system testing

Vdbench_run_def_fs_param

Resources:
Official doc: http://downloads.sourceforge.net/project/vdbench/vdbench502.pdf?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fvdbench%2Ffiles%2F&ts=1315925901&use_mirror=superb-sea2

Saturday, March 19, 2011

Japan earthquake GPS data visualization gadget

I made a gadget version of QuakeSim Japan earthquake data visualization portal. It shows data (longitude, latitude and height) collected by GPS stations during Japan earthquake.

You can click http://www.google.com/ig/adde?synd=open&source=ggyp&moduleurl=hosting.gmodules.com%2Fig%2Fgadgets%2Ffile%2F105322631994749779353%2Fquakesim-japan.xml to add it to your iGoogle. After it is added, maximize it by clicking the icon near top right corner of the gadget

Link for the gadget is

http://www.google.com/ig/directory?url=hosting.gmodules.com%2Fig%2Fgadgets%2Ffile%2F105322631994749779353%2Fquakesim-japan.xml

Thank Xiaoming Gao for providing service pages.

Wednesday, March 02, 2011

Install ns2 (ns-2.33) on Ubuntu Maverick

Install prerequisite:
sudo apt-get install \  
    tcl tcl-dev \ 
    libotcl1 libotcl1-dev  \ 
    tclcl-dev tclcl \ 
    tk tk-dev

./configure failed complaining that some tcl, tk related files cannot be found. It turns out those packages have been installed but file locations are different than what the configure script expects. Following is a fix.

You need to change two variables in file configure : TCL_TCL_PLACES and TK_TCL_PLACES.

Add
    /usr/share/tcltk/tcl$TCL_VERS \
    /usr/share/tcltk/tcl$TCL_HI_VERS
to variable TCL_TCL_PLACES.

Add
    /usr/share/tcltk/tk$TK_HI_VERS \
    /usr/share/tcltk/tk$TK_VERS"
to variable TK_TCL_PLACES.

execute ./configure

Official page: http://www.isi.edu/nsnam/ns/ns-build.html

Sunday, November 28, 2010

Some Hard Drive and File System benchmark tools

IOMeter

 

iozone

http://www.iozone.org

Document: http://www.iozone.org/docs/IOzone_msword_98.pdf
Manual: http://linux.die.net/man/1/iozone

Read, write, re-read, re-write, read backwards, read strided, fread, fwrite, random read/write, pread/pwrite variants

iozone -a | tee result.txt

iozone supports bunch of command line options. I summarized them in following table

Category Options Note
Auto mode -a: record size 4k - 16M, file size 64k - 512M.
-z: Used in conjunction with -a to test all possible record sizes. (Normally Iozone omits testing of small record sizes for very large files when used in full automatic mode. )
-A: more coverage
 
Test file -f filename: the name for temporary file under test.
-F fn1 fn2: # of files should be equal to # of processors/threads
 
Output -b filename: output of an Excel compatible file
-R: Generate Excel report.
 
Record size -r #: record size
-y #: minimum record size for auto mode
-q #: maximum record size for auto mode
 
File size -s #: size of the file to test
-g #: maximum file size for auto mode
-n #: minimum file size for auto mode
 
tests -i #: specifies which test to run
0=write/rewrite, 1=read/re-read, 2=random-read/write, 3=Read-backwards, 4=Re-write-record, 5=stride-read, 6=fwrite/re-fwrite, 7=fread/Re-fread, 8=mixed workload, 9=pwrite/Re-pwrite, 10=pread/Re-pread, 11=pwritev/Re-pwritev, 12=preadv/Re-preadv
One will always need to specify 0 so that any of the following tests will have a file to measure. This means -I 0 creates files used by following tests.
-i # -i # -i # is also supported so that one may select more than one test.
  -+p percent_reads: the percentage of threads/processes that will perform read testing in the mixed workload test case  
  -+B: sequential mixed workload testing  
throughput tests -t #: Run Iozone in a throughput mode.
-T: Use POSIX pthreads for throughput tests
This option allows the user to specify how many threads or processes to have active during the measurement.
processes/threads -l #: lower limit on number of processes to run
-u #: upper limit on number of processes to run
 
Timing -c: include close() in timing calculation
-e: include fflush(), fsync() in timing calculation
 
Other control -H #: Use POSIX async I/O with # async operations
-k #: Use POSIX async I/O (no bcopy) with # async operations.
-I: use direct I/O if possible
-m: use multiple buffers internally
-o: Writes are synchronously written to disk
-p: purges the processor cache before each file operation.
-W Lock file when reading or writing.
-K:  Inject some random accesses in the testing.
 
     

Examples

It's important to use -I option to turn on DIRECT I/O. Otherwise, linux's page caches (buffer cache) may give you ridiculous fast read speed.

  • Auto Mode

    • iozone -a -n 512m -g 1g

  • Single Test

    • Sequential write, Sequential reads
      iozone -r 64k -s 1g -b excel.xls -R -i 0 -i 1 -I
    • Use two processes to test sequential writes, sequential reads
      iozone -r 64k -s 1g -b excel.xls -R -i 0 -i 1 -I -l 2 -u 2
    • Use one and two processes to tests (two runs. In first run, one process is created. In second run, two processes are created)
      iozone -r 64k -s 1g -b excel.xls -R -i 0 -i 1 -I -l 1 -u 2
    • Random writes, Random reads
      iozone -r 64k -s 1g -b excel.xls-R -i 0 -i 1 -K -I
  • Throughput Test

    • iozone -t 2
      roughly equivalent to "iozone -l 2 -u 2"
  • Mixed Workload Test

    • iozone -r 64k -s 1g -b excel.xls -R -i 0 -i 8 -+p 50

Result visualization

./Generate_Graphs  result.txt

It will a directory for each operation (e.g. read, write, fread, fwrite). In each directory, there are two files generated - iozone_gen_out.gnuplot and <operation>.ps (this file is generated after you view the corresponding result using gnuplot).  Under the hood, it uses gnu3d.dem to render the data using Gnuplot after those data files are generated for all tested operations. You can call it directly without regenerating separate data files.

gnuplot gnu3d.dem

There are two more scripts that can be used for visualization - report.pl and iozone_visualization.pl.
When I tried to run them in Linux (using command ./report.pl result.txt), I had following error:

    -bash: ./iozone_visualizer.pl: /usr/bin/perl^M: bad interpreter: No such file or directory

You can use command perl report.pl result.txt to run it successfully.
The solution is to change those two files from dos type to unix type (mainly the new line character conversion).

sudo aptitude install tofrodos
fromdos report.pl
fromdos iozone_visualizer.pl

Now, you should be able to report.pl and iozone_visualization.pl directly. When they are run, a directory named 'report_result' is created. In the directory are Gnuplot scripts (*.do files) and PNG images for all tested operations. Those PNG images are generated by running those Gnuplot scripts. For example, read.png is generated by running "gnuplot read.do". A HTML page (index.html) is generated by iozone_visualization.pl which contains all of those PNG images in the same page.

Bonnie

http://www.textuality.com/bonnie/

Resources

Sunday, November 14, 2010

XLink

 http://www.xml.com/lpt/a/1038

Can be transformed to RDF?

One RDF use include to include other RDFs.

XLink and HLink: http://www.xml.com/lpt/a/1038

Enhancements to html link

  1. When to actuate the link
    In current html link impl, the link is actuated when it is clicked. In XLink and HLink, a link can be actuated when the page containing the link is loaded
  2. More effects when a link is actuated.
    embed, new, replace, etc.
  3. HLink supports creation of arbitrary link element.
    <hlink namespace="http://www.example.com/markup"
           element="home"
           locator="/"
           effect="replace"
           actuate="onRequest"/>
    <hlink namespace="http://www.example.com/markup"
           element="home"
           locator="/icons/home.png"
           effect="embed"
           actuate="onLoad"/>
    
    <home/>
  4. XLink supports creation of links among more than two resources.
  5. Add more metadata to links
  6. Links can be specified outside the linked resources.
    In HTML, users can only specify links within the source resource.
    When you write
     <a href=”destination.resource”>source</a>
    this piece of code must be located in the source html. In other words, the user cannot specify links among external resources.
    XLink adds this support.

 

METS, DIDL, ORE

http://www.oreillynet.com/xml/blog/2008/06/oaiore_compound_documents_draf.html

http://www.oreillynet.com/xml/blog/2008/05/bad_xml.html

http://www.dehora.net/journal/2008/06/18/dates-in-atom/

http://dret.net/netdret/docs/wilde-cacm2008-xml-fever.html

http://www.tbray.org/ongoing/When/200x/2006/01/09/On-XML-Language-Design

Wednesday, November 10, 2010

paratrac on Ubuntu

Compile ftrack

Dependencies

Depends on: fuse-dev, glib-dev, gthread-dev

    sudo apt-get install libfuse-dev  libglib2.0-dev

Use following commands to check whether they are installed successfully

    pkg-config --libs --cflags glib-2.0
    pkg-config --libs --cflags fuse

Build

cd fuse/ftrac/
./configure prefix=your_prefix
make
make install

Add ftrack to PATH:
  export PATH=your_prefix/bin:$PATH
  which ftrac

Use fusetrac.py

add parent directory of paratrac to PYTHONPATH

  python fusetrac.py -t /tmp/fuse/

FUSE FS is mounted and a monitoring page is shown. From now on, when you access /tmp/fuse, data on monitoring page will be changed.

  cd /tmp/fuse

Wednesday, November 03, 2010

Sunday, February 21, 2010

Syntax Highlighter syntax conversion

http://alexgorbatchev.com/wiki/SyntaxHighlighter 

I found that usage pattern was changed in recent releases.

Original sample usage:

<pre class="java:nocontrols" name="code">
    your code
</pre>

New sample usage:

<pre class="brush:java">
    your code
</pre>

Change your posts to use new version of Syntax Highlighter:

Invoke following command in vim:
%s/<pre \(.*\)class="\(\w\+\)*\(:\w\+\)*" \(.*\)>/<pre class="brush:\2" \1 \4>/g

Google Blogger/Blogspot line break conversion

Google Blogger/Blogspot new line conversion

Google blogger/blogspot provides an option to let users decide whether hard-returns in the post are converted to <br/>

Set it by clicking:
    Your blog admin page –> Settings -> Formatting -> Convert line breaks

Originally, I set it to "yes". Latter I decided to manually insert <br/> instead of using automatical hard-return conversion. So I set the option to "no". As a result, my previous posts were messed up because different lines were concatenated into a single line.

I used vim to convert those posts to new format.

Append <br/> to each line
    %s/$/<br\/>/g

Sometimes, you don't want to append new lines to block-level elements such as div, ol.
Use following vim commands:

    %s/\(<\/div>\s*\)\@<!$/<br\/>/g 
    %s/\(<\/ul>\s*\)\@<!$/<br\/>/g 
    %s/\(<\/ol>\s*\)\@<!$/<br\/>/g 
    %s/\(<\/dl>\s*\)\@<!$/<br\/>/g
    ......

Vim regular expression: http://vimdoc.sourceforge.net/htmldoc/pattern.html#pattern-overview

Another option is to write a script to download posts, adjust returns/newlines, and publish them.

Friday, January 08, 2010

Do you know Windows 7 GodMode?

See this post for details:

http://www.osnews.com/story/22691/Activate_Windows_7_s_Hidden_God_Mode_

Just try:

  1. Create a new folder
  2. Name it: GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}
  3. That's it

Thursday, December 24, 2009

A ball probability question

I was looking for a solution to a ball probability question which is described below. I found this page which exactly describes the same question: http://www.isibang.ac.in/~statmath/problems/august.html. However, it seems the page is not accessible now. So I copied the page and pasted it here. If this incurs any term/license problem, I am more than glad to remove the content.

Suppose Farrah gives you two bags. Bag A, contains 50 Red balls and Bag B, contains 50 Black Balls. She leaves the room asking you to rearrange the balls between the bags in any way you want without discarding any of the balls. She then returns and chooses a bag at random and then from the chosen bag, chooses a ball at random.

Question: Can you find the rearrangement that maximises her chance of choosing a black ball ?



Solution provided by Winners :

  • Soumya bhattacharya
    Clearly,if one bag contains only black balls and the other bag atleast one black ball along with the red balls,then the prabability that Farrah choses a black ball is more than half.

    Again if any of the bags contain equal no. of black and red balls ,then the other bag also contains them in equal number and (if none of them is an empty bag,in which case the probability of Farrah's chosing a black ball is only 1/4) the probability that Farrah choses a black ball is half.As we already have seen an example in which the probability of chosing a black ball is more than half,hence this case can't be the solution.

    So,if an optimal case exist,in that each of the bags must contain unequal numbers of black and red balls.And hence,(as the total no. of black balls= the total no. of the red balls) the proportion of black balls in a bag will be more than half in one bag and less than half,in the other. let 'b' and 'd' denote the total no. of balls in 2 bags and 'a' and 'c' denote the total no. of black balls in them respectively.

    W.L.O.G.,let us assume that a/b < 1/2 and c/d > 1/2.Now if we take out a black and a red ball from the 2nd bag and put them in the first,the probability of chosing a black ball changes from (1/2)*(a/b + c/d) to (1/2)*((a+1)/(b+2) + (c-1)/ (d-2)). Again as a/b < 1/2,hence we have (a+1)/(b+2) > a/b. And as c/d > 1/2, (c-1)/(d-2) > c/d.

    Therefore, by this rearrangement,the probability of chosing a black ball increases.So we do it untill there is no red ball in the bag,which was initially containing d balls.( as there were more black balls initially in this,and we shift equal no. of red and black balls to the other bag.) Now, clearly if we shift all the black balls,leaving only one in the first bag to the bag that contains red balls also,then the ratio of blacks to reds increases in the 2nd bag ,whereas that in the 1st bag remains constant, in effect increasing the probability of chosing a black ball by Farrah.

    So,starting with any arbitrary case we have reached the state of rearrangement, which has the probability of chosing a black ball more than or equal to that arbitrary case.So, we conclude that ,the rearrangement of the balls in which one bag contains only 1 black ball and the other bag contains the rest of the balls is maximum (0.7474).

  • Subhroshekhar Ghosh

    First of all, we claim that the required arrangement is : one black ball in one of the jars and all the other balls in the other jar, when the probability p of getting a black ball turns out to be 1/2*1 + 1/2 * 49/99.

    To, see this, we eliminate the cases 1.all the balls are in one jar (p=1/4) 2.there are equal no. of red and black balls in one jar (and hence in the other jar) (p=1/2).

    We observe that for any labelling of the jars as 1 and 2, p=1/2*p(1)+1/2*p(2) where p(i) is the conditional probability of getting a black ball having chosen the ith jar. Also, as there are equal no. of red and black balls, in any configuration there will be exactly one jar in which no. of red balls >= no. of black balls, hence the conditional probability for that jar <= 1/2. Since we have eliminated cases 1 and 2, we will have it < 1/2.

    Without loss of generality, we call this jar 1 and let it have r red and b black balls. Then p(1)=b/(r+b), b0. We have p(1)<1/2, so we consider 1/2 - p(1) = 1/2 * {(r-b)/(r+b)}. The restrictions imply (r-b)>= 1 and r+b <=99. Therefore, 1/2 - p(1) >= 1/2 * 1/99, so p(1) <= 49/99, equality holds if there are 50 red and 49 black balls in jar 1. The other conditional probability p(2) <= 1, equality holds if all balls in jar 2 are black. Hence, p will be maximised if both of these upper bounds are attained. But they are attained by the configuration mentioned in the beginning. In fact, it is clear from the equality conditions that this configuration is the only one that attains the upper bound.

  • Tuesday, December 22, 2009

    Interesting “Epigrams on Programming”

    Recently I found this

    Epigrams on Programming: http://www.pam1.bcs.uwa.edu.au/~michaelw/Perlis_Epigrams.html

    Really interesting, terse and helpful. Among those epigrams, I like following ones a lot

    1. Programming is an unnatural act.
    2. Computer Science is embarrassed by the computer.
    3. In man-machine symbiosis, it is man who must adjust: The machines can't.