Hello GIT
git clone ssh://laptop.local/Users/mjhsieh/amber11
Sometimes it's all about the aesthetics.
AWK can also be used to generate lazy code.
$ awk '/Block inner limits/{print $4,$5}' b37.out | awk '\
? NR==1 {printf "if ( h*i+gox >=%6.1f .and. h*i+gox <=%6.1f .and. &\n",$1,$2} \
? NR>1&&NR%3==1{printf "else if ( h*i+gox >=%6.1f .and. h*i+gox <=%6.1f .and. &\n",$1,$2}\
? NR%3==2 {printf " h*j+goy >=%6.1f .and. h*j+goy <=%6.1f .and. &\n",$1,$2}\
? NR%3==0 {printf " h*k+goz >=%6.1f .and. h*k+goz <=%6.1f ) then\n"$1,$2}\
? NR%3==0 {printf " write(%d,\47(4f)\47) mytmp,h*i+gox,h*j+goy,h*k+goz\n",8000+NR/3}'
Posted by
Mengjuei Hsieh
at
5:42 PM
Labels:
UNIX
0
comments
It has been very annoying that there is no intrinsic absolute function in awk, but it's still easy to do it by ourself:
$ paste tmp1/energy.txt tmp2/energy.txt tmp3/energy.txt tmp4/energy.txt \
? | awk 'function abs(x){return (((x < 0.0) ? -x : x) + 0.0)}\
? {printf "%s %25.12f %25.12f %25.12f %25.12f\n", $1,\
? abs($2-$2),abs($4-$2),abs($6-$2),abs($8-$2)}'
Posted by
Mengjuei Hsieh
at
3:36 PM
Labels:
Duh,
UNIX
1 comments
Right now there are at least two type of official package registering method in Mac OS X Leopard. The old style of package registering involves a bundled directory with literally no good way to manage it. The new style of package registry is a sqlite3 database, which is potentially a nice one. However according to the manual of pkgutil:
--forget package-id
Discard all receipt data about package-id, but do not touch
the installed files. DO NOT use this command from an
installer package script to fix broken package design.
SO YOU ARE NOT SUPPOSED TO FIX WHAT APPLE SHOULD HAVE DONE ALREADY.
Posted by
Mengjuei Hsieh
at
9:01 PM
Labels:
Apple,
UNIX
0
comments
#!/bin/bash
while true
do
tput sc
tput cup 0 60
echo -en `date +"%H:%M:%S %F"`
tput rc
sleep 1
done$ bash test.bash&
Posted by
Mengjuei Hsieh
at
12:30 AM
Labels:
Apple,
UNIX
0
comments
I am glad that this has been written already! [Guide to using Screen and irssi]
Posted by
Mengjuei Hsieh
at
2:15 PM
Labels:
UNIX
0
comments
$ osascript -e 'tell application "Microsoft Word" to close documents saving yes'
Posted by
Mengjuei Hsieh
at
1:22 PM
Labels:
Apple,
UNIX
0
comments

This is linux's top running with Nally's terminal emulation display. So far only top/vim/man are really tested.
Posted by
Mengjuei Hsieh
at
11:28 AM
Labels:
Apple,
UNIX
0
comments
rsync -e 'ssh -x host1 ssh' -avx --delete --bwlimit=1024 --exclude '*.spotlightIndex' host2:Documents/Papers/ Documents/Papers/
This let you synchronize files if you can't connect host2 directly and don't want to transfer it twice. However beware of the broadband problem since you might trigger DoS protection on host1... my solution is to add '--bwlimit=1024' ...
NETDEV WATCHDOG: eth0: transmit timed out tg3: eth0: transmit timed out, resetting tg3: tg3_stop_block timed out, ofs=2c00 enable_bit=2 tg3: tg3_stop_block timed out, ofs=1400 enable_bit=2 tg3: tg3_stop_block timed out, ofs=c00 enable_bit=2 tg3: tg3_stop_block timed out, ofs=4800 enable_bit=2 tg3: eth0: Link is down. tg3: eth0: Link is up at 100 Mbps, full duplex. tg3: eth0: Flow control is off for TX and off for RX. ... ...
Posted by
Mengjuei Hsieh
at
2:24 AM
Labels:
Fun,
UNIX
0
comments
Well, you can just allocate a big chunk of memory and release it to push some idle process to the virtual memory (swap).
program bigmem implicit none double precision, allocatable :: thebigmem(:) integer ierr ierr = 0 allocate ( thebigmem(1:195660000), stat=ierr ) if (ierr/=0) then; print *,"error allocating"; call exit(1); else; continue ; endif thebigmem = 0 deallocate ( thebigmem, stat=ierr) if (ierr/=0) then; print *,"error deallocating"; call exit(1); else; continue ; endif print *,"success" end programBut it's still like a placebo.
Posted by
Mengjuei Hsieh
at
4:09 PM
Labels:
Fun,
UNIX
0
comments
dscacheutil -flushcacheThis leopard command help you to reset corrupted DNS record that Safari refuses to forget.
lookupd -flushcacheIts equivalent command in tiger.
Posted by
Mengjuei Hsieh
at
11:21 PM
Labels:
Apple,
UNIX
0
comments
12:18 < abc> xyz: hey man, i love freebsd as much as the next guy, but its time to face realityFollowing figure is totally irrelevant.
12:18 < abc> xyz: there's also the issues of copyright indemnification
12:19 < abc> xyz: its a proven fact that linux torvalds borrowed AT&T code when he wrote FreeBSD
12:19 < abc> it was proven in court!
12:19 < abc> and you're a corporation running freebsd servers, you need support. who are you going to call? GNU?
12:20 < abc> i need support for windows servers... i call MS on the phone, give them my credit card number, and they fix my problem right there... BAM!
Posted by
Mengjuei Hsieh
at
12:41 PM
Labels:
Fun,
UNIX
0
comments
[localhost:~] johndoe% tcsh --version tcsh 6.14.00 (Astron) 2005-03-25 (powerpc-apple-darwin) options wide,nls,dl,al,kan,sm,rh,color,filec [localhost:~] johndoe% [localhost:~] johndoe% bash localhost:~ johndoe$ cd localhost:~ johndoe$ mkdir backup.tcshtest localhost:~ johndoe$ mv .history .login* .cshrc* .tcsh* backup.tcshtest/ localhost:~ johndoe$ curl http://mjhsieh.googlepages.com/history-crash -o .history localhost:~ johndoe$ bash -c 'LANG=en_US.UTF-8 tcsh' Segmentation fault localhost:~ johndoe$ bash -c 'LANG=C tcsh' [localhost:~] johndoe% [localhost:~] johndoe% exit localhost:~ johndoe$ rm .history localhost:~ johndoe$ bash -c 'LANG=en_US.UTF-8 tcsh' [localhost:~] johndoe% [localhost:~] johndoe% exit localhost:~ johndoe$ mv backup.tcshtest/.??* . localhost:~ johndoe$ exit [localhost:~] johndoe%
Posted by
Mengjuei Hsieh
at
7:59 PM
Labels:
UNIX,
WTF
0
comments
I was working on the inverse matrix the other day, it can be done through DGETRI of LAPACK. The DGETRI requires DGETRF to do LU decomposition first in order to calculate the inverse matrix. Then I found DGETRF interesting to start with since it has been awhile for me to touch linear algebra stuff. I wrote a "hello world" code for it. I was stuck on the issue to construct permutation matrix from IPIV, basically IPIV is not like vecP in Mathematica. This is how I understand it, I am not confident about the P matrix, this requires some LAPACK friends' help. On Mac OS X, just do g95 -framework Accelerate hello.f90 -o hellolapack and run the program by ./hellolapack , sorry I am too lazy to install a software lapack. :p
program hello
integer INFO
integer IPIV(3)
real*8 A(3,3),B(3,3),C(3,3),D(3,3)
real*8 P(3,3),L(3,3),U(3,3)
real*8 myVEC(3)
real*8 WORK(64*3)
A(1,1)=1d0
A(1,2)=2d0
A(1,3)=2d0
A(2,1)=2d0
A(2,2)=7d0
A(2,3)=7d0
A(3,1)=2d0
A(3,2)=7d0
A(3,3)=9d0
P=0d0
P(1,1)=1d0
P(2,2)=1d0
P(3,3)=1d0
! dgetrf(M,N,A,LDA,IPIV,INFO)
! input
! M The number of rows of the matrix A. M >= 0. Integer
! N The number of columns of the matrix A. N >= 0. Integer
! A The DP array
! output
! A The DP array
! LDA The leading dimension of the array A. LDA >= max(1,M).
! IPIV INTEGER array, dimension (min(M,N))
! The pivot indices; for 1 <= i <= min(M,N), row i of the
! matrix was interchanged with row IPIV(i).
print *,"A"
write (*,'(F8.3,F8.3,F8.3)') A(1,1:3)
write (*,'(F8.3,F8.3,F8.3)') A(2,1:3)
write (*,'(F8.3,F8.3,F8.3)') A(3,1:3)
B=A
call dgetrf(3,3,A,3,IPIV,INFO)
if (INFO.ne.0) stop
!IPIV(1)= 3 implies that the first and third rows were interchanged
!when factoring the first column; IPIV(2)= 3 implies that the second
!and third rows were interchanged when factoring the second column.
!In this case, IPIV(3) must be 3 because there are only three rows.
if (IPIV(1).eq.3) then
myVEC=P(1,1:3)
P(1,1:3)=P(3,1:3)
P(3,1:3)=myVEC
elseif(IPIV(1).eq.2) then
myVEC=P(1,1:3)
P(1,1:3)=P(2,1:3)
P(2,1:3)=myVEC
endif
if (IPIV(2).eq.3) then
myVEC=P(2,1:3)
P(2,1:3)=P(3,1:3)
P(3,1:3)=myVEC
elseif(IPIV(2).eq.1) then
myVEC=P(2,1:3)
P(2,1:3)=P(1,1:3)
P(1,1:3)=myVEC
endif
print *,"P"
write (*,'(F8.3,F8.3,F8.3)') P(1,1:3)
write (*,'(F8.3,F8.3,F8.3)') P(2,1:3)
write (*,'(F8.3,F8.3,F8.3)') P(3,1:3)
print *,"L"
L(1,1)=1d0
L(1,2:3)=0d0
L(2,1)=A(2,1)
L(2,2)=1d0
L(2,3)=0d0
L(3,1:2)=A(3,1:2)
L(3,3)=1d0
write (*,'(F8.3,F8.3,F8.3)') L(1,1:3)
write (*,'(F8.3,F8.3,F8.3)') L(2,1:3)
write (*,'(F8.3,F8.3,F8.3)') L(3,1:3)
print *,"U"
U(1,1:3)=A(1,1:3)
U(2,1)=0d0
U(2,2:3)=A(2,2:3)
U(3,1:2)=0d0
U(3,3)=A(3,3)
write (*,'(F8.3,F8.3,F8.3)') U(1,1:3)
write (*,'(F8.3,F8.3,F8.3)') U(2,1:3)
write (*,'(F8.3,F8.3,F8.3)') U(3,1:3)
call dgemm("N","N",3,3,3,1d0,L,3,U,3,0d0,C,3)
print *,"L.U"
write (*,'(F8.3,F8.3,F8.3)') C(1,1:3)
write (*,'(F8.3,F8.3,F8.3)') C(2,1:3)
write (*,'(F8.3,F8.3,F8.3)') C(3,1:3)
call dgemm("N","N",3,3,3,1d0,P,3,L,3,0d0,C,3)
call dgemm("N","N",3,3,3,1d0,C,3,U,3,0d0,D,3)
print *,"P.L.U"
write (*,'(F8.3,F8.3,F8.3)') D(1,1:3)
write (*,'(F8.3,F8.3,F8.3)') D(2,1:3)
write (*,'(F8.3,F8.3,F8.3)') D(3,1:3)
call dgetri(3,A,3,IPIV,WORK,64*3,INFO)
if (INFO.ne.0) stop
call dgemm("N","N",3,3,3,1d0,B,3,A,3,0d0,C,3)
print *,"A.A^-1"
write (*,'(F8.3,F8.3,F8.3)') C(1,1:3)
write (*,'(F8.3,F8.3,F8.3)') C(2,1:3)
write (*,'(F8.3,F8.3,F8.3)') C(3,1:3)
end program hello
Posted by
Mengjuei Hsieh
at
10:16 AM
Labels:
Science,
UNIX
1 comments
This seems to belong to "Wizard Level I/O"......orz
Recently g95 croaks some warning on Mac OS X platform like:
% g95 test.f90 /var/tmp//ccXFPLrz.s:59:indirect jmp without `*' ...It seems to be a known issue and the compiler still builds working binaries (assembly code? not sure). It is reasonable to get a wrapper script that filters out the warning. It turns out to be not as easy as I thought:
#!/bin/sh myg95="/opt/g95-install/bin/i386-apple-darwin*g95" exec 3>&1 $myg95 $* 2>&1 >&3 | grep -v "indirect jmp without " 1>&2 exec 3>&-This duplicates stdout to another file descriptor (3), then runs the g95 command with stderr redirected to stdout and stdout redirected to the saved descriptor (3). The result is piped into filter command to get rid of irreverent errors. The output of the pipeline is redirected back to stderr, so that stdout and stderr of the script as a whole are what it is expected.
Posted by
Mengjuei Hsieh
at
4:19 PM
Labels:
UNIX
0
comments
MyBundle.app MyBundle.app/Contents MyBundle.app/Contents/Info.plist MyBundle.app/Contents/MacOS MyBundle.app/Contents/MacOS/MyBundle MyBundle.app/Contents/MacOS/startup.command MyBundle.app/Contents/Resources MyBundle.app/Contents/Resources/MyIcons.icns(The name "MyIcons" is defined in Info.plist file.)
#!/bin/sh #File: MyBundle.app/Contents/MacOS/MyBundle mypath=`dirname "$0"` open $mypath/starup.commandWith this command file:
#!/bin/sh #File: MyBundle.app/Contents/MacOS/startup.command echo "this is a test" /bin/sleep 5This will give a terminal window with the output of "this is a test" and 5 seconds delay. Now you have a working application that can be put on the dock and also give you an opportunity to read the output!
#!/bin/sh
#File: MyBundle.app/Contents/MacOS/MyBundle
mypath=`dirname "$0"`
osascript << EOT
tell application "System Events" to set terminalOn to (exists process "Terminal")
tell application "Terminal"
if (terminalOn) then
activate
do script "\"$mypath/startup.command\"; exit"
else
do script "\"$mypath/startup.command\"; exit" in front window
end if
end tell
EOT
exit 0Time to fix the VMD.
Posted by
Mengjuei Hsieh
at
3:22 AM
Labels:
Apple,
UNIX
2
comments
Via Knight Feng, 咿咿咿批西 入手!
processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 13 model name : Intel(R) Celeron(R) M processor 900MHz stepping : 6 cpu MHz : 900.000 cache size : 512 KB fpu : yes fpu_exception : yes cpuid level : 2 wp : yes flags : fpu vme de pse tsc msr mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss tm pbe bogomips : 1261.26 clflush size : 64 MemTotal: 508328 kB 00:00.0 Host bridge: Intel Corporation Mobile 915GM/PM/GMS/910GML Express Processor to DRAM Controller (rev 04) 00:02.0 VGA compatible controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 04) 00:02.1 Display controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 04) 00:1b.0 Audio device: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) High Definition Audio Controller (rev 04) 00:1c.0 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 1 (rev 04) 00:1c.1 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 2 (rev 04) 00:1c.2 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 3 (rev 04) 00:1d.0 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #1 (rev 04) 00:1d.1 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #2 (rev 04) 00:1d.2 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #3 (rev 04) 00:1d.3 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #4 (rev 04) 00:1d.7 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller (rev 04) 00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev d4) 00:1f.0 ISA bridge: Intel Corporation 82801FBM (ICH6M) LPC Interface Bridge (rev 04) 00:1f.2 IDE interface: Intel Corporation 82801FBM (ICH6M) SATA Controller (rev 04) 00:1f.3 SMBus: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) SMBus Controller (rev 04) 01:00.0 Ethernet controller: Atheros Communications, Inc. AR5007EG 802.11 b/g Wireless PCI Express Adapter (rev 01) 03:00.0 Ethernet controller: Atheros Technology Corp. L2 100 Mbit Ethernet Adapter (rev a0) Bus 005 Device 003: ID eb1a:2761 eMPIA Technology, Inc. Bus 005 Device 002: ID 0cf2:6225 ENE Technology, Inc. Bus 005 Device 001: ID 0000:0000 Bus 004 Device 001: ID 0000:0000 Bus 003 Device 001: ID 0000:0000 Bus 002 Device 001: ID 0000:0000 Bus 001 Device 001: ID 0000:0000 [ 15.618272] eeepc_hotk: module license 'unspecified' taints kernel. [ 15.618901] Asus EEEPC HOTKEY [ 15.619223] [eeepc hotk] Hotkey init flags 0x41. [ 15.620795] [eeepc hotk] Get control methods supported : 0x101711
Posted by
Mengjuei Hsieh
at
1:34 AM
Labels:
UNIX
0
comments
Just got termatrix compiled in my powerbook, it looks like this toy can be used as a terminal emulator benchmark.
As I expected, xterm eats the least amount of CPU resource.
Posted by
Mengjuei Hsieh
at
2:20 AM
Labels:
UNIX
0
comments
The other days I was trying to port ASTROLOG to Mac OS X, the only official option for Mac OS X is thru X11 display. However you still need to modify the Makefile to make it work.
Before you port/compile the program by yourselves, you might want to try "Baby Astrolog"
If recompiling and X11 is what you want (since X11 version does have more functions). Try to use my patch to the Makefile. This patch is based on the UNIX source v5.4 of ASTROLOG:
The patch.
Also check momizi's astrolog story
Posted by
Mengjuei Hsieh
at
8:57 AM
Labels:
Apple,
UNIX
1 comments
Call me an one-line awk command freak. (sorry, it only processes integer seconds.)
awk -v shiftsec=2 '{\
if(/:..:.*:..:/){\
split($1,s1,","); split($3,s2,",");\
split(s1[1],s1t,":"); split(s2[1],s2t,":");\
time1=((s1t[1]*60+s1t[2])*60+s1t[3])+shiftsec;\
time2=((s2t[1]*60+s2t[2])*60+s2t[3])+shiftsec;\
ss1=time1%60;mm1=((time1-ss1)/60)%60;hh1=(time1-ss1-mm1*60)/60/60;\
ss2=time2%60;mm2=((time2-ss2)/60)%60;hh2=(time2-ss2-mm2*60)/60/60;\
printf("%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n",\
hh1,mm1,ss1,s1[2],hh2,mm2,ss2,s2[2]);\
}else{\
print $0\
}\
}' oldsrtfile.srt > newsrtfile.srt
I sorta wish I had used shell script at the beginning.
Posted by
Mengjuei Hsieh
at
3:25 AM
Labels:
UNIX
2
comments