From Doug: original post
Add the following lines to your .emacs or .emacs.d/init.el file to share the OS X clipboard with emacs.
From emacs inside the terminal in a “no window” mode. You can use M-w to copy something from emacs and then Cmd-V it in another Terminal window or likewise Cmd-C something in Terminal and then paste it into emacs with C-y.
(defun copy-from-osx ()
(shell-command-to-string "pbpaste"))
(defun paste-to-osx (text &optional push)
(let ((process-connection-type nil))
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))
(setq interprogram-cut-function 'paste-to-osx)
(setq interprogram-paste-function 'copy-from-osx)
Wednesday, September 30, 2009
Sunday, September 27, 2009
Install java script mode in emacs
From the terminal
wget http://code.google.com/p/js2-mode/wiki/InstallationInstructions
mv js2-20090723b.el ~/.emacs.d/lisp (js2-20090723b.el is the version at the time of writing)
#in Emacs
M-x byte-compile-file RET js2.el RET
#You need the following lines in your ~/.emacs file:
(add-to-list 'load-path "/export/home/user_name/.emacs.d/lisp") !!!change user_name accordingly!!!
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
#make sure the path is in your "load-path" variable:
C-h v:load-path
#Load the mode:
M-x js2-mode
wget http://code.google.com/p/js2-mode/wiki/InstallationInstructions
mv js2-20090723b.el ~/.emacs.d/lisp (js2-20090723b.el is the version at the time of writing)
#in Emacs
M-x byte-compile-file RET js2.el RET
#You need the following lines in your ~/.emacs file:
(add-to-list 'load-path "/export/home/user_name/.emacs.d/lisp") !!!change user_name accordingly!!!
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
#make sure the path is in your "load-path" variable:
C-h v:load-path
#Load the mode:
M-x js2-mode
remove duplicates from iTunes Music folder
Use fdupes
In the terminal:
sudo port install fdupes
cd ~/Music/iTunes/iTunes Music
fdupes -rf Music/ | tee duplicates.txt
(-r flag recursively reads subdirectories, -f omits the first match, tee redirects the output to a file)
#parse the duplicates file
sort duplicates.txt | uniq | grep -v '^$'
#remove the duplicates
while read line; do rm -v '$line'; done < duplicates.txt
#clean up
rm duplicates.txt
itunes will have broken links to the deleted files:
Within itunes I remove all files from my library choosing the "keep files" option, and drag the Music folder back into iTunes
In the terminal:
sudo port install fdupes
cd ~/Music/iTunes/iTunes Music
fdupes -rf Music/ | tee duplicates.txt
(-r flag recursively reads subdirectories, -f omits the first match, tee redirects the output to a file)
#parse the duplicates file
sort duplicates.txt | uniq | grep -v '^$'
#remove the duplicates
while read line; do rm -v '$line'; done < duplicates.txt
#clean up
rm duplicates.txt
itunes will have broken links to the deleted files:
Within itunes I remove all files from my library choosing the "keep files" option, and drag the Music folder back into iTunes
Thursday, August 20, 2009
Change dark blue directory color in Terminal 10.5 Leopard
The following will rid your Terminal of blue directory listings:
1. Add the following to ~/.profile :
alias ls='/bin/ls -G'
export LSCOLORS=exfxcxdxbxegedabagacad
2. Change the color(s) displayed by `ls` considering the following:
For each pair of characters in the string 'exfxcxdxbxegedabagacad', the first character in the pair represents the foreground color, the second character in the pair represents the background color. Changing the character changes the color; see the following chart:
a black
b red
c green
d brown
e blue
f magenta
g cyan
h light grey
A bold black, usually shows up as dark grey
B bold red
C bold green
D bold brown, usually shows up as yellow
E bold blue
F bold magenta
G bold cyan
H bold light grey; looks like bright white
x default foreground or background
Each character pair in the string 'exfxcxdxbxegedabagacad' represents a type of file displayed by `ls`. The breakdown of character pairs follows:
Pair 1 (ex) - directories
Pair 2 (fx) - symbolic links
Pair 3 (cx) - sockets
Pair 4 (dx) - pipes
Pair 5 (bx) - executable files
Pair 6 (eg) - block special
Pair 7 (ed) - character special
Pair 8 (ab) - executable with setuid bit set
Pair 9 (ag) - executable with setgid bit set
Pair 10 (ac) - directory writable to others, with sticky bit
Pair 11 (ad) - directory writable to others, without sticky bit
So, following this through to conclusion, the following is the list of default color pairs:
ex - blue/default - directories
fx - magenta/default - symbolic links
cx - green/default - sockets
dx - brown/default - pipes
bx - red/default - executable files
eg - blue/cyan - block special
ed - blue/brown - character special
ab - black/red - executable with setuid bit set
ag - black/cyan - executable with setgid bit set
ac - black/green - directory writable to others, with sticky bit
ad - black/brown - directory writable to others, without sticky bit
Finally, to change the listing of directories from blue to cyan, change the first character pair (ex) to (gx) in .profile :
export LSCOLORS=gxfxcxdxbxegedabagacad
3. To have the color change take effect, quit and restart Terminal, or run the following command:
. ~/.profile
1. Add the following to ~/.profile :
alias ls='/bin/ls -G'
export LSCOLORS=exfxcxdxbxegedabagacad
2. Change the color(s) displayed by `ls` considering the following:
For each pair of characters in the string 'exfxcxdxbxegedabagacad', the first character in the pair represents the foreground color, the second character in the pair represents the background color. Changing the character changes the color; see the following chart:
a black
b red
c green
d brown
e blue
f magenta
g cyan
h light grey
A bold black, usually shows up as dark grey
B bold red
C bold green
D bold brown, usually shows up as yellow
E bold blue
F bold magenta
G bold cyan
H bold light grey; looks like bright white
x default foreground or background
Each character pair in the string 'exfxcxdxbxegedabagacad' represents a type of file displayed by `ls`. The breakdown of character pairs follows:
Pair 1 (ex) - directories
Pair 2 (fx) - symbolic links
Pair 3 (cx) - sockets
Pair 4 (dx) - pipes
Pair 5 (bx) - executable files
Pair 6 (eg) - block special
Pair 7 (ed) - character special
Pair 8 (ab) - executable with setuid bit set
Pair 9 (ag) - executable with setgid bit set
Pair 10 (ac) - directory writable to others, with sticky bit
Pair 11 (ad) - directory writable to others, without sticky bit
So, following this through to conclusion, the following is the list of default color pairs:
ex - blue/default - directories
fx - magenta/default - symbolic links
cx - green/default - sockets
dx - brown/default - pipes
bx - red/default - executable files
eg - blue/cyan - block special
ed - blue/brown - character special
ab - black/red - executable with setuid bit set
ag - black/cyan - executable with setgid bit set
ac - black/green - directory writable to others, with sticky bit
ad - black/brown - directory writable to others, without sticky bit
Finally, to change the listing of directories from blue to cyan, change the first character pair (ex) to (gx) in .profile :
export LSCOLORS=gxfxcxdxbxegedabagacad
3. To have the color change take effect, quit and restart Terminal, or run the following command:
. ~/.profile
Wednesday, August 19, 2009
Install RPy 1.0.3 with R 2.9
Substitute line 77 of src/RPy.h
#include /* must follow Graphics.h */
with
#include /* must follow Graphics.h */
it builds and seems to work
from David Citarro
#include
with
#include
it builds and seems to work
from David Citarro
Saturday, March 28, 2009
How to publish python code in blogger
Thanks to Paddy.
import fileinput, re, cgi
def escape(lineiterator=fileinput.input,
cgi_escape=True, tag_with_pre=True, tag_with_br=False):
output = []
if tag_with_pre: output.append('<pre>\n')
for line in lineiterator:
if cgi_escape: line = cgi.escape(line)
line = re.sub(r'^(\s*)\s',
lambda m: ' '*m.end(),
line.rstrip())
output.append(line)
if tag_with_br:
output.append('<br>\n')
else:
output.append('\n')
if tag_with_pre: output.append('</pre>\n')
return ''.join(output)
Access PFAM domains from UniProt accessions using python
import xml.dom.minidom as minidom
def getPFamAnnotationByAcc(acc):
res_list = []
slurpp = pycurl.Curl()
slurpp.setopt(pycurl.URL, "http://pfam.sbc.su.se:43210/protein/%s"%acc)
slurpp.setopt(pycurl.POSTFIELDS, "output=xml")
file = open("tmp.xml", "w")
slurpp.setopt(pycurl.FILE, file)
slurpp.perform()
file.close()
#parse the PFam xml file searching for matches
dom = minidom.parse('tmp.xml')
for m in dom.getElementsByTagName('match'):
atts = m.attributes.items()
for l in m.getElementsByTagName('location'):
for t in l.attributes.items():
atts.append(t)
res_list.append(atts)
return res_list
Subscribe to:
Posts (Atom)