## S5 Reloaded themes with Sigma’s emacs org-mode method

In the past, I’ve described the benefits of a slide show based on html. I used to prefer the html5 method over S5, but after some use, I’ve come to realize that the html5 method (at least the one described here) isn’t ready for prime time yet. The display of the slides can get screwy. For example, the current slide might not be centered correctly. Therefore, I’m going to recommend the S5 system for html slide shows for now.

For use with Emacs org-mode, use Sigma’s method. Why? It is easier to change themes compared to Eric Schulte’s method (the latter method currently does not support a change in themes I think). In addition, it is compatible with the very good looking S5 Reloaded themes.

To change themes in the original S5 archive and have it work with emacs org-mode, copy ui/default/slides.js to ui/i18n/slides.js. To get S5 Reloaded themes to work, add jquery.js and org-slides.js from Sigma’s archive (in ui) into S5 Reloaded’s ui directory. Also, change /default/ to the desired location (theme) in S5.org from Sigma’s archive.

## Literature

Despite the availability of softwares such as Mendeley, Zotero, and JabRef, I like to store my papers (pdf files) and citation information (bib files) using a directory stucture, enter notes into a text file (org-mode), view notes and bibliographic information using a single file, cite references in LaTeX from a single bib file, and manage papers in Emacs using dired. I choose to manage my references using the bib format because it is the de facto standard in academia (at least in my field), and hence, is easily exported from the publisher’s website. In addition, I write all my papers using LaTeX for which I utilize bibtex whenever a reference is made; if I were to write papers using another program that utilizes a different format for bibliographies, I can easily convert the bib files using bibutils.

This post was originally motivated by this post which outlines a method to manage papers in emacs and org-mode. However, the workflow did not fit me particularly well, and so I came up with a setup and workflow of my own. I’ve been using this workflow for the last half a year and never got around to outlining it until the recent org-bibtex discussion reminded me to do so. I will first describe my setup and then its usage. I then end with some tips on starting your academic paper library and other thoughts. It is assumed that papers are available in pdf format. All filenames used throughout should not contain spaces, just to be safe.

### Setup

The base directory for the research papers I download and their corresponding bib files is ~/Documents/Literature. In this base directory, I have a folder scripts for storing scripts that help me manage the files. I also have the files books.bib and software.bib for storing citation information for books and software. The main files, bibliography.bib and literature.org are generated and updated using scripts and hence, are set to be non-writable by me in order to avoid manual editing that will be lost when the next update occurs.

I split my papers into subjects or categories according to directories in the base directory such as ./EstimatingEquations, ./Survival/, etc. In each of the subject directory, I have a category.org file that assists with structuring the literature.org file. An example of the category.org file:

* Estimating Equations :EstimatingEquations:



Place the following scripts in your script directory, ./scripts/.

LitNotes.sh:

#! /bin/bash

## template notes.org for a folder with bib.bib file

if [ -f bib.bib ]
then
if [ -s notes.org ] ## check if filesize is greater than 0 if it exists; FALSE if it does not exsist
then
echo "./notes.org has content (file size greater than zero.)!" && exit 1
else
## http://stackoverflow.com/questions/5162808/help-with-regex-extracting-text
author=$(sed -n '/^[[:blank:]]*author[[:blank:]]*=[[:blank:]]*{/ {s///; s/}[^}]*$//p}' bib.bib)
title=$(sed -n '/^[[:blank:]]*title[[:blank:]]*=[[:blank:]]*{/ {s///; s/}[^}]*$//p}' bib.bib)
year=$(sed -n '/^[[:blank:]]*year[[:blank:]]*=[[:blank:]]*{/ {s///; s/}[^}]*$//p}' bib.bib)
echo "** $author ($year) $title *** Notes " > notes.org fi else echo "No bib.bib in current directory." && exit 1 fi # ## following used on inside each category folder, eg, ./Survival; remember to edit tags in this script # for directory in ls -p | grep "/" # do # cd "$directory"
#     ##pwd
#     ##[ -f notes.org ] && echo "yes"
#     if [ -f notes.org ];
#     then
#         ## http://stackoverflow.com/questions/5162808/help-with-regex-extracting-text
#         author=$(sed -n '/^[[:blank:]]*author[[:blank:]]*=[[:blank:]]*{/ {s///; s/}[^}]*$//p}' bib.bib)
#         title=$(sed -n '/^[[:blank:]]*title[[:blank:]]*=[[:blank:]]*{/ {s///; s/}[^}]*$//p}' bib.bib)
#         year=$(sed -n '/^[[:blank:]]*year[[:blank:]]*=[[:blank:]]*{/ {s///; s/}[^}]*$//p}' bib.bib)
#         ##author=$(sed -n '/author *=/{s/^[^{]*{$$[^,]*$$,.*$/\1/;s/} *$//p}' ./bib.bib) ## does not work well because there could be commas in author # echo "**$author ($year)$title :Survival:
# *** Notes
# " ##> notes.org
#     fi
#     cd ..
# done


LitCreateDir.sh:

#! /bin/bash

## arguments are pdf files

for file in "$@" do bn=basename "$file"
NameNoExt=${bn%.*} ## no extension Ext=${bn/*./} ## extension http://www.linuxforums.org/forum/programming-scripting/128625-how-get-file-extension-without-dot.html
if [ echo $Ext | tr [:upper:] [:lower:]  = "pdf" ] ## only do pdf files then mkdir "$NameNoExt"
mv "$file" "$NameNoExt/"
touch "$NameNoExt/bib.bib" touch "$NameNoExt/notes.org"
if [ -f "$NameNoExt.bib" ] ## file exists? then mv -f "$NameNoExt.bib" "$NameNoExt/bib.bib" cd "$NameNoExt"
LitNotes.sh
cd ..
fi
fi
done


LitUpdate.sh:

#! /bin/bash

basedir="$HOME/Documents/Literature" bibfile="$basedir/bibliography.bib"
litfile="$basedir/literature.org" ## delete old files cd$basedir
rm -f $bibfile$litfile

## create $bibfile find ./ -iname "*.bib" -print0 | xargs -0 cat > /tmp/bibliography.bib ## -0, some folders have "'" in name; *.bib and not just bib.bib to get books.bib as well mv /tmp/bibliography.bib ./ # find ./ -iname "*.bib" -print0 > bibfiles.txt # xargs -0 cat < bibfiles.txt >$bibfile
## books
##cat books.bib >> $bibfile ## above should already pick up books ## create$litfile
echo "#+title: Literature
" >> $litfile for directory in ls -p | grep "/" ## directories in Literature do cd "$directory"
if [ -f category.org ]
then
cat category.org >> $litfile ##find ./ -iname "notes.org" -print0 | xargs -0 cat >>$litfile ## need to add in links to paper, location, bib, notes
for notes in find ./ -iname "notes.org"
do
fullpath=readlink -f "$notes" ##fullpath=realpath "$notes" ## http://www.commandlinefu.com/commands/view/7999/get-the-absolute-path-of-a-file?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Command-line-fu+%28Command-Line-Fu%29&utm_content=Google+Reader
paperdir=dirname "$fullpath" ## directory name of directory with notes.org pdf=find "$paperdir" -iname "*.pdf"
# cat "$notes" >>$litfile
# echo "*** [[file:$pdf][paper]] [[file:$paperdir/][location]] [[file:$paperdir/bib.bib][bib]] [[file:$paperdir/notes.org][notes]]" >> $litfile head -n1 "$notes" >> $litfile echo "*** [[file:$pdf][paper]] [[file:$paperdir/][location]] [[file:$paperdir/bib.bib][bib]] [[file:$paperdir/notes.org][notes]]" >>$litfile
sed '1 d' "$notes" >>$litfile
done
fi
cd ..
done

## make file read-only, so I have to manually go to the individual files to edit
chmod ugo=r $litfile$bibfile


Place the following in your emacs init file:

;; Literature
(defun dired-literature-create-directory-from-pdf ()
(interactive)
(save-window-excursion
(dired-do-async-shell-command
"$HOME/Documents/Literature/scripts/LitCreateDir.sh" current-prefix-arg (dired-get-marked-files t current-prefix-arg)))) (define-key dired-mode-map (kbd "s-l d") 'dired-literature-create-directory-from-pdf) (defun literature-update () (interactive) (shell-command "LitUpdate.sh") ) (global-set-key (kbd "s-l u") 'literature-update)  ### Usage I recommend the pdf file be named AuthorYearTitle.pdf to be consistent across all papers. The Title of course should be short and descriptive. Whenever I download a pdf paper, I make it MANDATORY that I also download the corresponding bib file (too many times did I have to cite a paper I thought I’d never cite). Nearly all publishers can export to bib, including JSTOR. If the publishing site doesn’t have this feature, I recommend googling the article in Google Scholar and exporting the bib file from the search results via “Export to BibTeX” (needs to be turned on in the Google Scholar settings); if this too isn’t available, then I will write my own bib file manually. Name this file AuthorYearTitle.bib, identically the same as the pdf file except the file extension (this is crucial for the scripts to work). I usually find myself visiting the downloaded bib file and editing it according to my preference. For example, I don’t like to have leading spaces in each line and I want each tag (e.g., journal) to be encapsulated by curly braces and end with a comma, even if it is the last tag. Also, make sure that there is at least one empty line at the end of the bib file; more on this in the “Other Thoughts” section. Suppose I downloaded these files in /tmp. In emacs, I will use dired to cut and paste these two files into the subject directory that it belongs to; for example, ./Survival. In dired, I will move the cursor to the pdf file and hit s-l d (d for directory); for multiple papers downloaded and moved at the same time, just mark the pdf files first before running s-l d. This will create a directory AuthorYearTitle in ./Survival for each marked paper, move the corresponding pdf and bib files into the newly created directory, and generate a templated notes.org whose content will be generated from the tags in the bib file: ** Author (Year) Title *** Notes  Things learned and notes regarding the content of the paper is meant to be typed into notes.org file so that I can review my thoughts later (and not have to necessarily re-read a paper to see what I learned). Why do I store each paper in its own directory? I want the paper, bib file, and my notes to be self-contained in a single entity, and a directory is the best way to achieve this goal. That way, I can move (to a new category?) or copy (send to a colleague?) the paper with all the information intact. After downloading new papers or moving papers around into a different (new?) categroy, running s-l u updates my bibliography.bib and literature.org file. All bib files (papers, books, and software) are concatenated into a single bibliography.bib file so that a single \bibliography{$HOME/Documents/Literature/bibliography.bib} can be inserted in all my LaTeX files that make use of references. All category.org and notes.org files are concatenated into a single literature.org file to create a single “library” where I can view all the available information; the paper, location, bib, and notes file can also be opened using C-c o (org-mode link). Since it is a text file, all the power of emacs (and other tools) can be used on this file: ordinary searches, regex searches, etc. This way, I can search my thoughts (via notes) to find or trace ideas back to a paper. Here is a snippet of what a generated literature.org file looks like:

#+title: Literature
#+author: MY NAME
#+email: MY EMAIL

* Estimating Equations :EstimatingEquations:
** White, Halbert (1982) Maximum Likelihood Estimation of Misspecified Models :EstimatingEquations:
*** [[file:/home/vinh/Documents/Literature/EstimatingEquations/White1982MLEMisspecifiedModels/White1982MLEMisspecifiedModels.pdf][paper]] [[file:/home/vinh/Documents/Literature/EstimatingEquations/White1982MLEMisspecifiedModels/][location]] [[file:/home/vinh/Documents/Literature/EstimatingEquations/White1982MLEMisspecifiedModels/bib.bib][bib]] [[file:/home/vinh/Documents/Literature/EstimatingEquations/White1982MLEMisspecifiedModels/notes.org][notes]]
*** Notes

** Whitney K. Newey and Daniel McFadden (1994) Chapter 36 Large sample estimation and hypothesis testing
*** Notes

** Cox, D. R. (1993) Unbiased Estimating Equations Derived from Statistics that are Functions of a Parameter
*** [[file:/home/vinh/Documents/Literature/EstimatingEquations/Cox1993UnbiasedEstEqDerived/Cox1993UnbiasedEstEqDerived.pdf][paper]] [[file:/home/vinh/Documents/Literature/EstimatingEquations/Cox1993UnbiasedEstEqDerived/][location]] [[file:/home/vinh/Documents/Literature/EstimatingEquations/Cox1993UnbiasedEstEqDerived/bib.bib][bib]] [[file:/home/vinh/Documents/Literature/EstimatingEquations/Cox1993UnbiasedEstEqDerived/notes.org][notes]]
*** Notes

...

* Genetics :Genetics:
** French, Benjamin and Lumley, Thomas and Monks, Stephanie A. and Rice, Kenneth M. and Hindorff, Lucia A. and Reiner, Alexander P. and Psaty, Bruce M. (2006) Simple estimates of haplotype relative risks in case-control data
*** [[file:/home/vinh/Documents/Literature/Genetics/FrenchLumley+Others2006HaplotypesRelativeRisk/FrenchLumley+Others2006HaplotypesRelativeRisk.pdf][paper]] [[file:/home/vinh/Documents/Literature/Genetics/FrenchLumley+Others2006HaplotypesRelativeRisk/][location]] [[file:/home/vinh/Documents/Literature/Genetics/FrenchLumley+Others2006HaplotypesRelativeRisk/bib.bib][bib]] [[file:/home/vinh/Documents/Literature/Genetics/FrenchLumley+Others2006HaplotypesRelativeRisk/notes.org][notes]]
*** Notes

** Follmann, Dean and Proschan, Michael and Leifer, Eric (2003) Multiple Outputation: Inference for Complex Clustered Data by Averaging Analyses from Independent Data
*** [[file:/home/vinh/Documents/Literature/Genetics/FollmanProschanLeifer2003MultipleOutputation/FollmanProschanLeifer2003MultipleOutputation.pdf][paper]] [[file:/home/vinh/Documents/Literature/Genetics/FollmanProschanLeifer2003MultipleOutputation/][location]] [[file:/home/vinh/Documents/Literature/Genetics/FollmanProschanLeifer2003MultipleOutputation/bib.bib][bib]] [[file:/home/vinh/Documents/Literature/Genetics/FollmanProschanLeifer2003MultipleOutputation/notes.org][notes]]
*** Notes

** Lin, D.Y. and Zeng, D. and Millikan, R. (2005) Maximum likelihood estimation of haplotype effects and haplotype-environment interactions in association studies
*** [[file:/home/vinh/Documents/Literature/Genetics/LinZengMillikan2005MLEHaplotype/LinZengMillikan2005MLEHaplotype.pdf][paper]] [[file:/home/vinh/Documents/Literature/Genetics/LinZengMillikan2005MLEHaplotype/][location]] [[file:/home/vinh/Documents/Literature/Genetics/LinZengMillikan2005MLEHaplotype/bib.bib][bib]] [[file:/home/vinh/Documents/Literature/Genetics/LinZengMillikan2005MLEHaplotype/notes.org][notes]]
*** Notes

** Lin, DY and Zeng, D. (2006) Likelihood-based inference on haplotype effects in genetic association studies
*** [[file:/home/vinh/Documents/Literature/Genetics/LinZeng2006LikelihoodInferenceHaplotype/LinZeng2006LikelihoodInferenceHaplotype.pdf][paper]] [[file:/home/vinh/Documents/Literature/Genetics/LinZeng2006LikelihoodInferenceHaplotype/][location]] [[file:/home/vinh/Documents/Literature/Genetics/LinZeng2006LikelihoodInferenceHaplotype/bib.bib][bib]] [[file:/home/vinh/Documents/Literature/Genetics/LinZeng2006LikelihoodInferenceHaplotype/notes.org][notes]]
*** Notes

...



Note that the update process can take seconds or more due to the concatenation. My library is ever-growing so it will only get longer and longer to update. I’m not sure if I can ever speed up this process (let me know if you have ideas).

After running the update process, reftex-reset-mode should be run in an opened LaTeX file if you want to make use of the most current information with RefTeX.

I make use of emacs’s bookmark capabalities (C-x r b) to visit these files easily in emacs.

### Getting started

Most researchers have their downloaded pdf files in one location or multiple locations (category). To get started, I recommend spending time to rename the files according to AuthorYearTitle.pdf, and downloading or creating a separate bib file for each paper. Then place the files into their category directories (create category.org as well). In emacs dired, mark all the pdf files in each category, run s-l d to generate a self-contained directory for each paper. After this is done on all the categories, run s-l u to update. The file bibliography.bib can now be used in your LaTeX documents. The file literature.org can be now be used as an all in one library.

### Other thoughts

Each bib file should have at least one empty line at the end of the file or things may go wrong in the bibliography.bib file; this paper is concatenated from multiple files, and multiple lines could be joined into one line if the newline character isn’t present at the end of the file.

I also have a bibliography.tex file to generate a pdf file with all my papers:

\documentclass{article}
\usepackage{fullpage}
\usepackage{natbib}

\begin{document}

\cite{*}
\bibliographystyle{apa}
\bibliography{bibliography}

\end{document}


One thing I would like to be able to do is edit the literature.org file (notes portion) directly and have the changes reflected in the individual notes.org files. I haven’t thought of a process to do this well. It would be nice to view multiple files in a single buffer as if the buffer is showing a single file so that when I edit a portion of the buffer, it actually is a different file depending on its location.

I’m not sure if anyone will find my workflow useful, but I just wanted to document it for the masses.

## Non-LaTeX presentations using org-mode – S5 and HTML5 slides

I recently had frustrations with presentations written using MS Powerpoint; I’m not even going to mention KeyNote as it is only available on a Mac. LibreOffice is my WYSIWYG editor on my Linux machine for writing quick and nicely formatted content. I also have MS Office installed on my machine using WINE. I sometimes use Google Docs for presentation when I have to collaborate. Most of the times, viewing MS-generated files on LibreOffice suffices. When it doesn’t work well, I opt for MS Office. However, I recently had to open a powerpoint presentation with an audio link. It didn’t play on LibreOffice and it didn’t play on my WINE MS Office. I started thinking about a possible route for presentation files that are self-contained and cross-platform. PDF comes to mind first, but to do so would mean I have to use Beamer to generate the slides or to use Adobe Acrobat to create the slides. I don’t want to do either as I’m referring to the scenario of creating quick slides.

HTML came to my mind next. I recalled S5. I remember this post which outlines how one could export to S5 using org-mode. I tried it out finally and things work nicely. This tutorial also mentions an alternative method to generate S5 presentations in org-mode based on the org-export-as-s5 function. Hopefully it will be integrated in the MASTER branch of org-mode soon. To embed audio or video, just paste the html code an html chunk, linking the file multimedia file in the current directory. Now the directory could be transferred to any computer and viewed.

I also stumbled on this link, which allows me to export org files to HTML5 slides. I think the latest file is here, with instructions on how to set up in the comments.

With the S5 and HTML5 slides exporting methods in org-mode, now I can make cross-platform presentations very easily using org-mode. I will probably use the HTML5 method as it doesn’t come with any dependencies like the ui directory from S5.

## File associations in Linux (Gnome and Mailcap)

File associations in Linux can be tricky. On my Gnome-based Ubuntu machine, I can associate a filetype by right-clicking a file in Nautilus, and slecting “Open with”. To modify the defaults using config files, this post describes it well. Basically, the two main locations to check out are /usr/share/applications/defaults.list and ~/.local/share/applications/. File associations made using these methods apply to the commands gnome-open and xdg-open as well.

File associations in the command line is mainly done via MIME types (I think). At least file associations in conkeror, org-mode’s org-open-at-point (also look at org-file-app), and the see commands are done by MIME. MIME handlers are defined in a user’s ~/.mailcap file.

I think this information is enough to modify default apps throughout Linux. Do see this post where I outline how I launch all my files using Emacs’ dired mode. Now I can launch apps more uniformly in Nautlius, Emacs, and on the command line based on configuring default apps.

## Presentations/slideshows in a web browser using S5

I use LaTeX Beamer whenever I write a a presentation because

1. I’m familiar with LaTeX and want to keep up with the skillset,
2. I prefer to write in plain text, especially in emacs, and
3. I don’t have to spend time working on the how the presentation looks and just have to worry about content.

I recently re-discovered S5, a way to make presentations using html, viewable by any web browser. I think it is safe to assume that more computers have a web browser than a pdf viewer (especially more than MS Powerpoint, for sure). I don’t really know html, so I searched for org-mode or markdown support. Of course, these exist. For org-mode, check out org-s5. For markdown support, there is Instiki and pandoc. I hope to try these out soon. S5 seems to be a good alternative when my presentation doesn’t involve math equations or source code on display. You can also create Beamer slides easily using org-mode; see this and this.

## Bash batch script to convert org-mode file to html

I recently read this on reddit. I adapted the script on there to convert multiple org-mode files to html files. If you use it make sure you adapte the location of org-mode and your org.el file. Enjoy.

 <pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /bin/</span><span style="color: #00ffff;">bash</span>


## http://www.reddit.com/r/emacs/comments/dy9yt/anyone_know_of_a_script_that_i_can_feed_an/ ## http://www.ibm.com/developerworks/library/l-bash2.html ## http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/ f=“” for file in “$@” do ##emacs –batch -q –no-site-file –eval “(add-to-list ‘load-path “~/.emacs.d/org-mode/lisp/”)” –load$HOME/.emacs.d/org-mode/lisp/org.el –visit ${file} –funcall org-export-as-html-batch f=“${f} –visit ${file} –funcall org-export-as-html-batch” done emacs –batch -q –no-site-file –eval “(add-to-list ‘load-path “~/.emacs.d/org-mode/lisp/“)” –load$HOME/.emacs.d/org-mode/lisp/org.el $f ## use emacsclient, check if running, execute. otherwise u this ## NO, emacsclient takes in elisp argument with –eval, not list list of files (will need to write my own elisp function…not worth effort) ## Moved to WordPress for technical blogging So I’ve decided to move my technical blog to wordpress, the .org version, not the .com version; that is, to host my own instance of wordpress. The move came from various reasons: 1. syntax highlighting for soure codes, 2. LaTeX support for my stat/math display, 3. post via email, 4. post via emacs, 5. text-to-html syntax for blogging (think org-mode), 6. easy to backup, 7. all these features must be permanent (ie, the services above cannot be changed and my posts no longer look “right”), and finally, 8. extensible Points 4, 5, and 8 were never addressed with blogger, and point 2 was not consistent (contradicts point 7). Posterous seemed very nice when i tried it out (especially point 3), but it didn’t seem too good for points 1 and 2 (although points 2 can be addressed by mathurl or Sitmo’s Equation Editor based on this post). I tried wordpress.com once, but thought it was inadequate. I knew it was possible to install your own wordpress version on a server but thought it was too much of a hassle. However, out of the blue I looked into the above features and found that wordpress had plugins (point 8) that really much fulfilled a lot of my needs. I will outline how I installed wordpress on my school’s server and how I customized it to give me the features I want. I pretty much followed the instructions from wordpress. My server already had apache on it, so I installed the following in addition: <pre class="src src-sh">sudo apt-get update  sudo apt-get install php5 sudo apt-get install mysql-server sudo apt-get install php5-mysql ## mod_rewrite Apache module already installed wget http://wordpress.org/latest.tar.gz tar xvf latest.tar.gz mysql -u root -p ## enter password In mysql, I have to set up the user and password: <pre class="src src-sql">CREATE USER <span style="color: #ffa07a;">'ENTER MY USERNAME'</span>@<span style="color: #ffa07a;">'localhost'</span> IDENTIFIED BY <span style="color: #ffa07a;">'ENTER MY PASSWORD'</span>;  GRANT ALL PRIVILEGES ON . TO ‘ENTER MY USERNAME’@‘localhost’ WITH GRANT OPTION; EXIT I also have to set up a database for the blog’s data by: <pre class="src src-sh">mysql -u USERNAME -p  CREATE DATABASE wordpress; GRANT ALL PRIVILEGES ON wordpress.* TO "ENTER MY USERNAME"@"localhost" IDENTIFIED BY "Enter WordPress Password"; FLUSH PRIVILEGES; EXIT  We also need to update the wp-config.php file: <pre class="src src-sh">emacs -q -nw wp-config.php <span style="color: #ff4500;">## </span><span style="color: #ff4500;">follow instructions in above site, generate random key, and set table_prefix to "snc_" for supernerdycool</span>  cd ~/ cd blog.nguyenvq.com cp -rf ~/Downloads/wordpress/* ./ sudo emacs -q -nw /etc/apache2/conf.d/virtual.conf sudo emacs -q -nw /etc/apache2/conf.d/virtual.conf ## make sure it looks like following: # # We’re running multiple virtual hosts. # NameVirtualHost * ## done ## make sure following is in /etc/apache2/httpd.conf: LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so sudo emacs -q -nw /etc/apache2/sites-available/blog.nguyenvq.com place following in it: # # Example.com (/etc/apache2/sites-available/adrc.nguyenvq.com) # # Basic setup ServerAdmin EnterMyEmail ServerName blog.nguyenvq.com DocumentRoot /path/to/blog.nguyenvq.com # HTML documents, with indexing. Options Indexes FollowSymLinks MultiViews ## enable site sudo ln -s /etc/apache2/sites-available/blog.nguyenvq.com /etc/apache2/sites-enabled/blog.nguyenvq.com sudo /etc/init.d/apache2 restart ## go to http://blog.nguyenvq.com/wp-admin/install.php in web browser I initially had some errors with mysql and php, but this showed me that I was missing mysql-php in the install (apt-get); restart apache again. To install plugins, it is easiest to have an ftp server set up for the server. I installed it via “apt-get install proftpd ## select standalone.” I addressed what I wanted above with: 1. SyntaxHighlighter Evolved, 2. wp-latex, 3. postie (require php5-imap for imap) or wordpress’s native email support (this didn’t work too well for me’) – email does not work well with wp-latex and syntaxhighlighter as this modifies the incoming text, 4. weblogger mode in emacs (turn on xml-rpc in wordpress), 5. Markdown for WordPress and bbPress 6. backup by using rsync (for wordpress files) and mysqldump for the database (data), 7. since these are installed on my own server, of course all these services are permanent (of course I can move them to another server too), 8. other plugins: Akismet, WP-reCAPTCHA, Acronyms, Search and Replace (very good for updating all posts), Search Unleashed(uncheck “Some themes don’t display any search result content. Enable this option to force the theme to display results” in options or when visiting post from google search result, syntax highlighting will get screwed up), ShareThis (share to twitter, facebook, …, all social media), and Simple Image Widget. The SyntaxHighlighter Evolved and Markdown didn’t play nicely together. This post’s comments has the solution, by wrapping the source code chunk with the div tag and changing the add_filter line in markdown to 9 (see below). Since this is hard to display, I will describe the characters in text: <pre class="src src-sh">LeftAngleBracket div RightAngleBracketDiv LeftSquareBracket bash RightSquareBracket  my code LeftSquareBracket FORWARD SLASH bash RightSquareBracket LeftAngleBracket FORWARD SLASH div RightAngleBracket Also change markdown.php: <pre class="src src-php">add_filter('the_content_rss', 'Markdown', 6);  ## to add_filter(‘the_content_rss’, ‘Markdown’, 9); ## syntax highlighter’s is less than 9 See this site for the lnaguages supported. For LaTeX, include code by: <pre class="src src-sh">DOLLARSIGN latex ENTER LATEX CODE DOLLARSIGN  to get $$latex y=x’\beta_0$$. For Markdown syntax, look at this site for a quick reference. The main thing is to use two asterisks (\/\/) around the text for bold and one asterisk (\*) around the text for italics. For links, use <pre class="src src-sh">LeftSquareBracket TEXT RightSquareBracket LeftParen URL RightParen  . There are a lot more, but these will be commonly used. I would like the syntax to be like that of org-mode, but I can’t have everything. I could hack the php file to modify the syntax like org-mode’s, but I’m too lazy now and don’t want to deal with the regexp’s. I also like the notepad theme as it fits my technical blog quite nice. backup wordpress site: <pre class="src src-sh">rsync -av --modify-window=1 --delete username@myserver:location localLocation  ## this backs up to my computer backup database and some cron scripts (multiple scripts in the following): <pre class="src src-sh"><span style="color: #ff4500;">### </span><span style="color: #ff4500;">http://codex.wordpress.org/Backing_Up_Your_Database</span>  mysqldump –add-drop-table -u MyUsername -p Databasename | bzip2 -c > blog.nguyenvq.com.bak.sql.bz2 ## wordpress is the database name, -p says to specify password after ## now enter password #### restore database ### http://codex.wordpress.org/Restoring_Your_Database_From_Backup bzip2 -d blog.nguyenvq.com.bak.sql.bz2 mysql -u MyUserName -p Databasename < blog.nguyenvq.com.bak.sql ## enter password #### setup cron job on server Backup_blog.nguyenvq.com_DB.sh: #! /usr/bin/env bash mysqldump –add-drop-table -u MyUsername –password=MYPASSWORD Databasename | bzip2 -c > /path/to/blog.nguyenvq.com.bak.sql.bz2 chmod +x Backup_blog.nguyenvq.com_DB.sh chmod o-r Backup_blog.nguyenvq.com_DB.sh crontab -e: 00 12 * * * /path/to/Backup_blog.nguyenvq.com_DB.sh 59 23 * * * /path/to/Backup_blog.nguyenvq.com_DB.sh ## need a carriage return at end of file #### setup cron job on my computer ## make sure passwordless ssh is on Backup_blog.nguyenvq.com.sh: #! /usr/bin/env bash INCREMENT=date +%Y%m%d%H%M DIR=“$HOME/path/to/wherever” DIR=“$HOME/path/to/wherever/Wordpress_blog.nguyenvq.com” # -q for quiet in cron rsync -q -av –modify-window=1 –delete username@server:/path/to/blog$DIR0/ scp -q username@server:/path/to/nguyenvq.com.bak.sql.bz2 $DIR/blog.nguyenvq.com.bak.sql.$INCREMENT.bz2 find $DIR -mtime +14 -exec rm -f {} \; ## delete files older than 14 days crontab -e: 02 12 * * * /path/to/Backup_blog.nguyenvq.com.sh 02 00 * * * /path/to/Backup_blog.nguyenvq.com.sh ## global hotkey / keyboard shortcut in Mac OS X to bring up remember buffer in emacs: record a new thought or TO DO task anywhere This method worked for me, and this didn’t. I added the following in my .emacs file: <pre class="src src-sh">;; Emacs server on by default  (server-start) ;; http://metajack.im/2008/12/30/gtd-capture-with-emacs-orgmode/?dsq=13708223#comment-13708223 ;; together with the apple script C-M-\ anywhere in Mac to bring up the remember buffer ;; C-c C-c to save in ~/.notes and close; (require ‘remember) (defadvice remember-finalize (after delete-remember-frame activate) “Advise remember-finalize to close the frame if it is the remember frame” (if (equal “remember” (frame-parameter nil ‘name)) (delete-frame))) (defadvice remember-destroy (after delete-remember-frame activate) “Advise remember-destroy to close the frame if it is the rememeber frame” (if (equal “remember” (frame-parameter nil ‘name)) (delete-frame))) ;; make the frame contain a single window. by default org-remember ;; splits the window. (add-hook ‘remember-mode-hook ‘delete-other-windows) (defun make-remember-frame () “Create a new frame and run org-remember.” (interactive) (make-frame ‘((name . “remember”) (width . 80) (height . 10))) (select-frame-by-name “remember”) (org-remember)) I used this applescript with spark and bound it to C-M-\ : property eclient : <pre class="src src-sh"><span style="color: #ffa07a;">"/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -e '(make-remember-frame)'"</span>  do shell script eclient tell application “Emacs” activate end tell Now, wherever im at in Mac, i just hit C-M-\ and my remember buffer will be brought up. I type what my thoughts are. Hit C-c C-c to save and close buffer. When I have time, go to ~/.notes and organize my thoughts, and finish the to-do tasks. Set the ending of that file as: ## Captures Anything i add will be under ** Date, and after that will be my notes. So remember-mode is org-mode! ## org-mode: outlines & meeting minutes + others (create / export html) So I’ve recently discovered org-mode for emacs. I don’t need to put much references up as a simple google search for org-mode should yield many references, especially its home page (there, u can find many references to start using org-mode). It has many features, but what I personally will use often is outlining and taking notes, especially making meeting agendas and meeting minutes [for my youth group]. I love how easy it is to move things around, and especially how you can export it to ascii, latex/pdf, and html; i usually export to html (C-c C-e h or C-c C-e b), and print to pdf. I don’t think i will use the agenda and calendar system often; even though i love emacs, i rely on google calendar for this stuff since i sync things to my phone, ical (mac), on the web, etc…i have access to my calendar anytime and anywhere. Also, org-mode has a great html export, has a great table mode (for latex AND html). you can reference things very easily (html), and can create html projects. I might consider doing this for some of my websites in the near future (although i am following in love w/ google sites, it is not 100% suitable for all situations). This is what I have in my .emacs file for org-mode: <pre class="src src-sh">;; Org-mode settings  (require ‘org-install) (require ‘org) (add-to-list ‘auto-mode-alist ‘(“\.org$” . org-mode)) (global-set-key “\C-cl” ‘org-store-link) (global-set-key “\C-ca” ‘org-agenda) (global-font-lock-mode 1) ;; turn on soft wrapping mode for org mode (add-hook ‘org-mode-hook (lambda () (setq truncate-lines nil))) (setq user-mail-address “vinhdizzo@gmail.com”)

Here is a video that the creator of org-mode gave at google corp:

NOTE: On my Mac, I’m using carbon emacs (22), and it comes with a very OLD version of org-mode. I had to: delete the org files in Applications/Emacs.app/Contents/Resources/lisp/textmodes and download and install the new org-mode. I added where files are in (path) into .emacs: