set guioptions+=a
Tuesday, 13 December 2011
Friday, 25 November 2011
Monday, 17 October 2011
Make Matlab writable by pipes
mkfifo matin
Matpipe:
#!/bin/bash
((tail -f ~/matin | tee >(cat 1>&2)) & cat) | matlab
Writemat
#!/bin/bash
cat $@ | tee ~/matin
Vim function
vmap :call ExecuteMatlab()
function! ExecuteMatlab() range
:'<,'>!writemat
endfunction
Then pipe commands to matin.
This prints stuff sent to matin to the stdin of matlab and also to stderr, as well as able to read from the stdin of the terminal.
Keyword: process substitution - >(....) creates a temporary file in bash and feeds stuff to that process.
Matpipe:
#!/bin/bash
((tail -f ~/matin | tee >(cat 1>&2)) & cat) | matlab
Writemat
#!/bin/bash
cat $@ | tee ~/matin
Vim function
vmap
function! ExecuteMatlab() range
:'<,'>!writemat
endfunction
Then pipe commands to matin.
This prints stuff sent to matin to the stdin of matlab and also to stderr, as well as able to read from the stdin of the terminal.
Keyword: process substitution - >(....) creates a temporary file in bash and feeds stuff to that process.
Friday, 19 August 2011
Save wrong line bash
A simple thing to do when you realize you just typed the wrong line is hit Ctrl+C; if you want to keep the line, but need to execute something else first, begin a new line with a back slash - \, then Ctrl+C. The line will remain in your history.
Latex Dashes
Hyphen: daughter-in-law, X-rated\\
En dash: pages 13--67\\
Em dash: yes---or no? \\
Minus sign: $0$, $1$ and $-1$
En dash: pages 13--67\\
Em dash: yes---or no? \\
Minus sign: $0$, $1$ and $-1$
Bash trim filename
However, buried in there is a section on Parameter Substitution which tells us that $foo is really a shorthand for ${foo} which is really the simplest case of several ${foo:operators} and similar constructs.
- Given:
- foo=/tmp/my.dir/filename.tar.gz
- We can use these expressions:
- path = ${foo%/*}
- To get: /tmp/my.dir (like dirname)
- file = ${foo##*/}
- To get: filename.tar.gz (like basename)
- base = ${file%%.*}
- To get: filename
- ext = ${file#*.}
- To get: tar.gz
-
- ${variable%pattern}
- Trim the shortest match from the end
- ${variable##pattern}
- Trim the longest match from the beginning
- ${variable%%pattern}
- Trim the longest match from the end
- ${variable#pattern}
- Trim the shortest match from the beginning
Thursday, 10 February 2011
Subscribe to:
Posts (Atom)