Below is a little code I use with ksh. The wt() function can only be expected to work in an X-term. The code sequences are different for other terminal emulators.
DIRSTACK=$PWD function dirs { print $DIRSTACK } function pushd { dirname=$1 cd ${dirname:?"missing directory name."} DIRSTACK="$PWD $DIRSTACK" } function popd { DIRSTACK=${DIRSTACK#* } top=${DIRSTACK%% *} cd $top } function rfind { dir=$PWD while [ ! -e $1 ]; do if [ $PWD == "/" ]; then command cd $dir return 1 else command cd .. fi done rfdir=$PWD command cd $dir return 0 } function wt { printf "ESC]0;${@/$HOME/'~'}^G" } function git_dir { typeset str rfdir="" rfind '.git' if [ $? -eq 0 ]; then str="\{`git branch | grep '*' | cut -d ' ' -f 2`\}" wt "[${rfdir}${str}]" else wt "xterm" fi echo "$str" } function mkprompt { typeset branch branch=`git_dir` PS1="${branch}$ " } function cd { PS1="$ " command cd $@ mkprompt }
Tags: programming, sh
I’m planning to drive this blog in a slightly different direction. That is, I want to narrow down what I write about here to a few categories that interest me most, instead of shooting off in all directions with no depth in any of them. Of course, I still reserve the right to write about any topic at any time, but…
Anyhoo, the average reader should get what I’m saying.
In that vein, here’s a little bit more math geekery; Euler’s formula. This is not new in any way, or even something that isn’t blogged on often (it is, and by people who are far more knowledgeable, talented, and better at writing about math) and in true blog tradition, I’m swiping it wholesale from someone else. Go there to see a better explanation for all this.
[tex]e^{i\phi} = cos(\phi) + i sin(\phi)[/tex]
Let [tex]\phi = \pi[/tex], and you end up with
[tex]e^{i\pi} = – 1[/tex]
which leads to a striking equation that links together the most commonly used constants in mathematics:
[tex]e^{i\pi} + 1 = 0[/tex]
Interestingly, if you let [tex]\phi = \frac{\pi}{2}[/tex], then you get
[tex]e^{i\frac{\pi}{2}} = i[/tex]
Raising both sides to the power [tex]i[/tex], you get
[tex]e^{-\frac{\pi}{2}} = i^i[/tex]
Which can be calculated as [tex]i^i = 0.2078795763\cdots[/tex]
Tags: math
As Joi Ito said, too funny not to blog. I know it’s old, but I still laughed out loud:
After explaining to students through various lessons and examples that
[tex]\displaystyle \lim_{x\to 8} \frac{1}{x-8} = \infty[/tex].
I tried to check if she really understood that, so I gave her a different example; the result of which was:
[tex]\displaystyle \lim_{x\to 5} \frac{1}{x-5} = \rotatebox{90}{5}[/tex].
Hah!
Tags: math
I saw the recent announcement that wordpress.com now supports native latex equations. The posted examples are pretty sweet, and the syntax is just fine: $latex
I thought to myself, “boy, I sure would like to have that on my blog. I bet it’s just a wordpress plugin.” That’s apparently not the case for wordpress.com. I don’t know what they’re using. However, I did find the LatexRender plugin by Steve Mayer. Even better though, I found Gunnlauger’s installation script over at Fugato. Why all wordpress plugins don’t have some automated install mechanism, I’ll never guess. Downloading zips and extracting them really sucks, but this script is handy.
Let’s test the results by typesetting some of Euler’s work:
| [tex]\displaystyle e^{{\it i}\theta}[/tex] | [tex]\displaystyle =[/tex] | [tex]\displaystyle cos \theta + i sin \theta[/tex] |
| [tex]\displaystyle e[/tex] | [tex]\displaystyle =[/tex] | [tex]\displaystyle \sum\limits_{n=0}^\infty {\frac{1}{n!}}[/tex] |
| [tex]\displaystyle =[/tex] | [tex]\displaystyle \lim\limits_{n\to\infty} {\left(\frac{1}{0!} + \frac{1}{1!} + \frac{1}{2!} + \cdots + \frac{1}{n!} \right)}[/tex] | |
| [tex]\displaystyle J[/tex] | [tex]\displaystyle =[/tex] | [tex]\displaystyle \int_{a}^{b} F\left(t, f(t), f^{\prime}(t)\right) d{\sl t}[/tex] |
Pretty slick, I have to say. It’s not perfect though; because of the lack of a good standard for typesetting math on the web, these things still have to be done with images. MathML is pretty neat and I think it’s probably the future, but not every browser treats it the same (or at all, for that matter). It’s just not ready yet. Also, not every [tex]\LaTeX[/tex] technique will work. For the above, I tried using the “tabular” environment, but it didn’t come out right because the ampersands got converted to character codes – I eventually had to use tables to get the spacing I wanted.
Anyway, all in all, this plugin is pretty cool. It even adds a ‘tex’ button to the post editing page.
Tags: math