Friday, November 28, 2014

FreeDNS Cron Update

A Dynamic DNS Bash Script for FreeDNS
First, make sure you have registered an account for FreeDNS, and set up a subdomain as an A record at

Save the contents below as, making sure to change /path/to/log/dns.log , <YOUR_API_KEY> , <YOUR_SUBDOMAIN>. You can get both your API Key and the domain from . The domain should be something like (or or one of the other FreeDNS domains).

You can get the full update line (https address and the full wget call, seen in the if statement below) from your FreeDNS dashboard, under Main Menu -> Dynamic DNS -> quick cron example , toward the bottom of the page.

echo "-----------------------" >> $LOG                                          
echo "Running" >> $LOG                                                   
echo $(date) >> $LOG                                                            
# get the current ip...                                                         
CURRENT_IP=$(wget -q -O -|sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
echo "Current IP:"$CURRENT_IP >> $LOG                                           
#FreeDNS updater script                                                         
PREVIOUS_IP=$(nslookup $SUBDOMAIN | tail -n2 | grep A | sed s/[^0-9.]//g)                
echo "Previous IP:"$PREVIOUS_IP >> $LOG                                         
if [ "$CURRENT_IP" != "$PREVIOUS_IP" ]                                          
        echo "Current and previous IP differ! Updating FreeDNS..." >> $LOG      
        wget -q -O /dev/null $UPDATE_URL                                         
        echo "DNS updated on:"$(date) >> $LOG                                   
echo "-----------------------" >> $LOG

Now run sudo vim /etc/crontab , adding this line at the bottom,
replacing /path/to/script/ with the path you saved to,
and replacing <USER> with your username
*/5 * * * * <USER> /path/to/script/

Tuesday, August 12, 2014

Install Acrobat Reader in Ubuntu

cd ~/Downloads && wget -c

sudo dpkg -i AdbeRdr9.5.5-1_i386linux_enu.deb

For 64 bit, you also need compatibility libs:
sudo apt-get install libgtk2.0-0:i386 libnss3-1d:i386 libnspr4-0d:i386 lib32nss-mdns libxml2:i386 libxslt1.1:i386 libstdc++6:i386

Tuesday, July 22, 2014

Checking Out GitHub PRs

Example .git/config

[remote "upstream"]                                                            
    url =                         
    fetch = +refs/heads/*:refs/remotes/upstream/*                              
    fetch = +refs/pull/*/head:refs/remotes/upstream/pr/*

Tuesday, July 8, 2014

Saturday, June 7, 2014

Force google-chrome to start new session

This command will force Google Chrome to start a new session, and disables any proxy settings you currently have

google-chrome --user-data-dir=/tmp --no-proxy-server

Thursday, June 5, 2014

Data portals

SOCKS proxy with firefox about:config and ssh

A simple socks proxy can be made as follows

First, open Firefox and type about:config in the address bar

change the following items

network.proxy.socks localhost
network.proxy.socks_port 4321

network.proxy.type 1
network.proxy.socks_remote_dns true

ssh to your favorite machine with the -D flag

ssh -D 4321

This will setup a SOCKS proxy to and also protect your DNS requests


Unmount busy filesystem and find process linux

sudo umount /mntumount: /mnt: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))

bash            19005       user  cwd DIR   8,17        4096         2           /mnt

sudo kill -9 19005

Set iptables rulesets

Redirecting traffic to different ports - in this caser, redirect standard http requests and https requests to a server which doesn't run as root (all ports < 1000 require root access)

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8443

To show the new rules, do

iptables -t nat --list

Setting up emacs24 and clojure starter kit


sudo add-apt-repository ppa:cassou/emacs
sudo apt-get update
sudo apt-get install emacs-snapshot

Once the ppa and emacs are installed, start emacs by doing emacs-snapshot. Hit C-x C-f (Ctrl and x, then Ctrl and f) and type in the path ~/emacs.d/init.el . Add the following text to this file

(require 'package)
(add-to-list 'package-archives
             '("marmalade" . "") t)

Now do M-x eval-buffer, then M-x package-refresh-contents, then M-x package-install. When prompted, type starter-kit. Now you are off! I also installed starter-kit-lisp

Most of the above information is just parroting the information found at the following links.

Installing EVIL mode for VIM keys

M-x package-install RET evil RET 

M-x package-install RET evil-leader RET

M-x package-install RET evil-numbers RET 

Now add the following line to ~/.emacs.d/init.el

(evil-mode 1) 
Other packages




Using evolution with an exchange server

First, install the evolution, evolution-mapi, and evolution-exchange packages. On CentOS 6.3, this was accomplished by the command sudo yum install evolution evolution-mapi evolution-exchange.

When setting up the account, select Exchange MAPI for the Server Type on the Receiving Email tab. It may also be necessary to use the IP address of your Exchange server, instead of the name. The domain name should be the prefix you normally see on your Windows login i.e. WONDERCO/jdoe could be


Username: jdoe

Domain name:WONDERCO

IMPORTANT: Before you click View->Calendar, disable the "Prefer Plain Text" plugin by going to Edit->Plugins, then unchecking the "Prefer Plain Text" box. I didn't do this, and got trapped in the calendar, which would freeze evolution every time it was launched. If this happens, reset your settings by following the instructions at the link below.


Get full kernel source for CentOS 6.X and compile against it

First, follow the instructions from the link below to get the full kernel source. To confirm that this was actually a complete kernel, I also performed a make in ~/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/ . This compiled the entire kernel, and proved to me that this was the full kernel source (unlike the packages kernel-devel and kernel-headers).

Once the "test build" was complete, I needed to build my kernel module against that kernel source. This was accomplished by doing ./configure --kernel-source-path=/home/myname/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/ , followed by make && make install

Transferring files with netcat

On the destination server, set up a listen port by doing nc -l PORT > FILENAME, where PORT is the listen port to connect to, and  FILENAME is the filename you want to have on the destination server. This could be any number, but you probably want it to be >1000 due to Linux rules about ports.

Now on the source server, do

nc IP PORT < FILE, where IP is the ip of the destination server, PORT is the same as above, and FILE is name of the file to transfer.

An example, with IP =, PORT = 9001, FILE=backup.iso


nc -l 9001 > backup.iso


nc 9001 < backup.iso

Changing finch keybindings

Switching to XMonad can create a keybinding conflict with Finch. To correct this, create a file named ~/.gntrc with the following text

c-n = window-next
c-p = window-prev
c-r = start-resize
c-t = start-move           

Add a buddy in finch (commandline pidgin)

Press Ctrl-o (also written c-o) to access the actions windows, where you can add buddies, plugins, and other things

Install Skype on ubuntu 12.10

After downloading the 64 bit Ubuntu 10.04 .deb package from, I tried to install with dpkg -i

sudo dpkg -i skype-ubuntu_4.0.0.8-1_amd64.deb

This returned with:

dpkg: dependency problems prevent configuration of skype:
 skype depends on lib32stdc++6 (>= 4.1.1-21); however:
  Package lib32stdc++6 is not installed.
 skype depends on lib32asound2 (>> 1.0.14); however:
  Package lib32asound2 is not installed.
 skype depends on ia32-libs; however:
  Package ia32-libs is not installed.
 skype depends on libc6-i386 (>= 2.7-1); however:
  Package libc6-i386 is not installed.
 skype depends on lib32gcc1 (>= 1:4.1.1-21+ia32.libs.1.19); however:
  Package lib32gcc1 is not installed.

To get skype working properly, the following steps must be taken

sudo dpkg -r ia32-libs

sudo apt-get update

sudo apt-get install -f

After this, running

sudo dpkg -i skype-ubuntu_4.0.0.8-1_amd64.deb

should install skype.

Setting power to suspend on XMonad laptop

You will need the acpi program for this change to work - do a

sudo apt-get install acpi

After this, simply change the line in /etc/acpi/ that says

. /usr/share/acpi-support/screenblank


echo -n mem > /sys/power/state

Adding a .cls file to latex

Add a line to ~/.bashrc that points to your .cls files

The . in front is critical to source the current directory

For example, my github ( has an IEEEtran file that has the IEEE standard template inside. To use it, simply add this line to ~/.bashrc

export TEXINPUTS=.:<path_to_IEEEtran_file>:$TEXINPUTS

now running texi2pdf should compile IEEE format .tex files

Fixing matlab under XMonad

After switching to XMonad, I still couldn't get MATLAB to work properly

The fix is to add the line

import XMonad.Hooks.SetWMName

at the top of xmonad.hs, and then

startupHook = setWMName "LG3D"

under the defaultConfig section of xmonad.hs

Make mac boootable USB in Ubuntu

Put in a USB device, then do

dmesg | tail

Depending on what /dev/sdX device is listed, do

mkfs.vfat /dev/sdX -I

Note, the above command WILL wipe the USB drive!

Now take the downloaded .ISO, and do

dd of=/dev/sdX if=<path_to_.iso> bs=1M

Reboot the Mac, while holding Alt. A boot prompt should come up and allow you to boot from the USB.

Set custom videomode for correct resizing of virtualbox guest OS

First, you will need to install the Guest Additions for the VM you wish to resize. For most Linux VMs, this requires installing the latest kernel and kernel headers. To get the kernel and  kernel headers in CentOS, run sudo yum -y install kernel kernel-devel

Once this is done, reboot the VM. This should use the latest kernel (which was just installed) allowing for successful building of the main Guest Additions module. To build the Guest Additions, go to Devices->Install Guest Additions in the Virtualbox menu. You should now be able to autorun the Guest Additions software (it should show up as a CD) in the VM. There may still be other issues, typically OpenGL fails to build, but generally the main Guest Additions module is all that is necessary for screen resizing.

vboxmanage setextradata "Z7" "CustomVideoMode1" "1280x650x32"

Where Z7 is the name of the VM, and 1280x650x32 is the custom resolution you desire. In Ubuntu, you can take a stab at what your monitor resolution is by running xrandr. You can get a list of VM names by doing

vboxmanage list vms

Change screen brightness from commandline

There is usually a program /usr/bin/intel_backlight that will allow you to set the backlight setting

/usr/bin/intel_backlight xx

where xx is some value between 0 and 100

For older systems, use

sudo setpci -s 00:02.0 f4.b=xx

where xx is 00-FF, and 00:02.0 is my VGA display device as shown by lspci

Alternatively, for newer devices which use the intel_backlight interface, use this command

echo xx | sudo tee /sys/class/backlight/intel_backlight/brightness

where xx is anything from 0 (this will blank out your screen...) to whatever is displayed by cat /sys/class/backlight/intel_backlight/max_brightness

Though it changes more than just brightness, the command

xgamma -gamma xx

where xx is anywhere from 0->1.5 will also change the screen. You can go higher than 1.5, but I haven't tried anything higher.

Cronjob to change screen brightness

Tired of your backlight resetting every time you boot your laptop or set it to hibernate? Create a new file containing the following content in /usr/local/bin, and name the file check_backlight



for i in `seq 1 $\$$LOOP_COUNTER`; do


    BRIGHTNESS_COMMAND='/usr/bin/intel_backlight '

    if [ $\$$BRIGHTNESS -ne $\$$DESIRED_BRIGHTNESS ]; then

        eval $\$$BRIGHTNESS_COMMAND
    sleep $\$$WAIT_TIME


Now add the following line to /etc/crontab

* *     * * *   root    /bin/bash /usr/local/bin/check_backlight

This entry in crontab will run the script /usr/local/bin/check_backlight every minute. The check_backlight script loops for 60 seconds, checking the backlight every WAIT_TIME seconds.

Setup fake ethernet device with any MAC address

sudo modprobe dummy
sudo ip link set name eth0 dev dummy0

sudo ifconfig eth0 hw ether 00:24:49:03:1a:72

Launch matlab in 32bit mode

matlab -glnx86

Add ssh key for GitHub

ssh-keygen -t rsa -C <email here>

sudo apt-get install xclip

xlip -sel clip < ~/.ssh/

Now just add the key through the github interface
To make the repo push over ssh

git remote rm origin
git remote add origin

To add the upstream repo and synch with it

git remote add upstream
git fetch upstream
git checkout master
git pull --rebase upstream master

Find key maps in XMonad

Running the program xev and then looking at the output can tell you the key mapping for a key to put in xmonad.hs

Add user to vboxusers group to enable VM USB support

sudo usermod -a -G vboxusers $USER

Create a pdf from many images

convert *.jpg images.pdf

Adding latex support to a blog (like this one!)

To add LaTeX support to a blog, simply add this script under your Layout->HTML/JavaScript settings

<script type="text/javascript" src=""> MathJax.Hub.Config({ extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"], jax: ["input/TeX", "output/HTML-CSS"], tex2jax: { inlineMath: [ ['$\$$','$\$$'], ["\(","\)"] ], displayMath: [ ['$\$$$\$$','$\$$$\$$'], ["$\backslash [$","$\backslash ]$"] ], }, "HTML-CSS": { availableFonts: ["TeX"] } });< /script>

I have forgotten where I got this tip, but whoever originally posted this - thank you!

Resize many gif images using imagemagick

for i in *.gif; do convert $\$$i -resize 400x400 $\$$(basename $\$$i .gif).gif; done

wget files of a certain type in all subdirectories

wget -r -A .gif <website>

Show status of dd command

Run dd with something like

sudo dd if=/dev/zero of=/dev/sdx

Now in another terminal, do ps ax| grep dd

Look at the process id (first column) of the dd command

Use that process id as input for

sudo kill -SIGUSR1 <pid>

This will force dd to print a status update

PXE boot args for disabling nouveau

Doing lsmod | grep nouveau showed nouveau drivers being loaded, even though I had the following PXE boot args

append initrd=myrd.gz root=/dev/ram0 rdblacklist=nouveau nouveau.modeset=0 init=/bin/init ramdisk_size=800000 ramdisk_blocksize=1024 rw
Noveau was still loading, but adding nouveau.blacklist=1 solved it, like so:

append initrd=myrd.gz root=/dev/ram0 nouveau.blacklist=1 rdblacklist=nouveau nouveau.modeset=0 init=/bin/init ramdisk_size=800000 ramdisk_blocksize=1024 rw

There is also a nouveau.disable=1 option, which I did not try

Make a bootable USB

Copy the .iso file to /dev/sdx (NOT /dev/sdx1)

dd bs=4M if=/path/to/iso of=/dev/sdx

When finished, make sure to zero out the boot record and non-standard partition table:

dd count=1 bs=512 if=/dev/zero of=/dev/sdx

Making a pdf from an IPython notebook

With the latest ipython one can run ipython nbconvert latex mynotebook.ipynb. The latest ipython can currently be installed from, at the time of this writing this is the 1.0 development stream.

ipython nbconvert latex mynotebook.ipynb will result in a latex file. texi2pdf should then be able to convert this tex file into a viewable pdf - in my case I had to manually copy all the files and images out of the associated mynotebook_files directory to the same directory as the .tex file, both of which were generated by ipython nbconvert. If you encounter latex errors, see for installation instructions for the latest latex. The default Ubuntu texlive package (as of 13.04 at least) is not recent enough to perform the conversion!

Copy files over ssh

dd if=input | ssh login@remotehost "dd of=output"

Wednesday, June 4, 2014

Inspect disk statistics with smartctl

smartctl -a -d megaraid,0 /dev/sdx

Compile Ubuntu packages from source

apt-get source <package> (NOTE: no sudo!)

sudo apt-get build-dep <package>

Update firmware for older Dell servers

Download the CentOS LiveDVD from here:

next, copy it to a usb drive with dd:

sudo dd if=<path to CentOS iso> of=/dev/<my usb drive> bs=4096

This image should have all the latest firmware built into it. I used this to update BMC firmware for the Dell R900.

There is a blog by Dell about this procedure as well, shown here:

OpenWRT on DIR 601 Rev B1

Have to use the NA file, because the other file won't get recognized as firmware.

Once that is done, telnet into to set up OpenWRT

uci del wireless.@wifi-device[0].disabled

uci del wireless.@wifi-iface[0].network

uci set wireless.@wifi-iface[0].mode=sta

uci commit wireless


iw wlan0 scan

then follow the steps here

Make sure to change the LAN settings to a subnet not shared by the "mothership" router! And also encryption type is PSK2 for WPA/WPA2 mixed mode - iw wlan0 scan did not show the same output as the steps on the page.

To change the default LAN IP of the D-Link network, simply edit /etc/config/network

Get full structure of website

wget \
     --recursive \
     --no-clobber \
     --page-requisites \
     --html-extension \
     --convert-links \
     --restrict-file-names=windows \
     --no-parent \

Friday, February 7, 2014

Zipit Z2 Information

Based on debian sid.
2 users set up by default. root password root. user password user.
The system auto logs in as user at boot and starts the desktop environment.
The keymapping is standard to the other zipit userlands.
The smily face = esc
The zipit key = tab
Alt = alt
… = ctrl
D-pad = arrow keys
Options key turns on and off the mouse (d-pad)
Mouse buttons are: center of d-pad = right click, stop button = left click

Commonly asked “where are these keys?”
alt+next = ~
ctrl+backspace = | (NOTE: on my version this is ALT+Smiley)
alt+. = }
alt+, = {
shift+. = >
shift+, = <
ctrl+shift+j = (
ctrl+shift+k = )
alt+prev = scroll up (in irssi)
alt+next = scroll down (in irssi)
shift+prev = scroll up (in terminal)
shift+next = scroll down (in terminal)

Keybindings for desktop shortcuts:
ctrl+m = menu
ctrl+t = terminal
ctrl+r = run prompt
ctrl+l = close window
ctrl+n = next window
ctrl+p = previous window
ctrl+q = backlights off
ctrl+w = backlights on

To adjust lcd and keyboard backlights manually, run as root:
lcd max high med low off
keys max high med low off