Tuesday, November 9, 2010

Amazon EC2

Steps for setting up a free ec2 micro account:
  • Sign up for a free ec2 account
    • You will need to create a new AWS account if you already have one
  • Log into the AWS Management Console
  • Create a micro Linux account - choose an EBS backed AMI (Official Ubuntu AMI's are uploaded by user 099720109477)
  • Make sure security group has SSH access
  • Download pem file (can store in same directory or ~/.ssh/identity - ~/.ssh/id_dsa for newer ssh versions)
  • chmod 400 [KEY].pem
  • From folder of pem file connect with: ssh -i [KEY].pem ec2-user@[ID].compute-1.amazonaws.com (user name may be root or ubuntu, depending on instance)
  • Send files with: scp -i [KEY].pem file [USER]@[ID].compute-1.amazonaws.com:
  • Mount filesystem: sshfs [USER]@[ID].compute-1.amazonaws.com: ~/mnt -o IdentityFile=[KEY].pem
  • Unmount: fusermount -u ~/mnt

Format harddrive

ls -l /dev/disk/by-id/

Look for required harddrive

sudo mkfs.ext3 /dev/sdb1 -L "Buffalo"

Monday, August 30, 2010

Grep-fu

How to display list of files with given extension with given text:
grep -lr --include="*.py" "firefox_" *

Sunday, July 11, 2010

Installing Crunchbang

  • Download Crunchbang development torrent
  • Format USB as FAT32
  • Download recent version of unetbootin
  • Create Debian Unstable HDMedia environment on USB
  • Copy Crunchbang ISO to USB at root
  • Boot from USB to install

Post install:
  • Add account to sudoers with visudo
  • Add http://ftp.debian.org/debian/ and http://www.debian-multimedia.org/ to /etc/apt/sources.list
  • Add "setxkbmap us &" to ~/.config/openbox/autostart.sh to set US keyboard
  • install ttf-* packages for foreign fonts (Chinese: arphic-uming, Korean: unfonts-extra)
  • Install vim, codecs, etc
  • Customize .vimrc, .bashrc

    Monday, July 5, 2010

    iso install

    1. Find path to USB with: ls -l /dev/disk/by-id/*usb*
    2. Format USB to FAT32: sudo umount /dev/sdx && sudo mkfs.vfat -I -n "custom name" /dev/sdX
    3. Replug USB
    4. Write ISO to usb with: sudo dd if=/path/to/iso of=/dev/sdX bs=4M;sync (or use UNetbootin)
    5. Make USB first in BIOS boot order (hit F2 or Del at startup)

    Thursday, July 1, 2010

    OCR for Linux

    I tried a few solutions to extract text out of a clear image containing alan0@hotmail.com:
    Install with: sudo apt-get install gocr tesseract ocrad

    $ gocr -i email.png
    aIan0hdmaiI.com

    $ convert email.png email.tif # requires tif
    $ tesseract email.tif out
    $ cat out.txt
    Ina rrykeeg a

    $ convert email.png email.ppm # requires p[bgp]m
    $ ocrad email.ppm
    alano_no_mall.


    Upscaling the image slightly improved the results but still none were correct.
    Disappointing ...

    Wednesday, June 30, 2010

    web2py on webfaction

    In Panel create a custom script and then paste this URL: http://wiki.webfaction.com/wiki/Web2py-LatestSource

    Monday, June 28, 2010

    Tor on Ubuntu

    I found Tor works with privoxy but not the recommended polipo on Ubuntu 9.10. To run tor first add the following to /etc/apt/sources.list:
    deb http://deb.torproject.org/torproject.org [distribution] main
    For me the [distribution] is Karmic.


    Now install Tor and the proxy server with:
    1. sudo aptitude install tor privoxy
    2. sudo vim /etc/tor/torrc and modify MaxCircuitDirtiness
    3. sudo vim /etc/privoxy/config
    4. comment out: “logfile logfile”
    5. find: listen-address 127.0.0.1:8118
    6. add (on next line): forward-socks4a / localhost:9050 . (including the period)
    7. sudo /etc/init.d/tor restart && sudo /etc/init.d/privoxy restart

    Now set 127.0.0.1:8118 as proxy (eg in firefox) to access the Tor network.

    Saturday, May 29, 2010

    GAE domains

    How to register a domain with godaddy and enable free hosting on Google:
    • Purchase domain from godaddy
      • This will use the default godaddy nameservers (ns35.domaincontrol.com, ns36.domaincontrol.com, etc)
    • Set up Google Apps for domain
      • Complete signup form and request cname value to verify domain
    • Login to godaddy domain manager (advanced)
      • Add www forwarding to get naked domain to work (use masking)
      • Delete all the default cname values, which point to various services
      • Add google.com cname value and use default TTL
      • Add cname ghs.google.com with alias www
    • Add www sub domain through GAE dashboard
    • To enable email use this service
    • Had to wait 10 minutes before service was active

    Monday, May 3, 2010

    SSH timeouts

    Add this to ~/.ssh/config to avoid ssh timeouts (create file if does not exist):

    Host *
        ServerAliveInterval 240

    Saturday, May 1, 2010

    Call url with CRON

    Call URL periodically with CRON, discard HTML, and send all output (including errors) to file:

    $ crontab -e
    0 * * * * wget URL -O /dev/null 2>> ~/cron.log

    Memcached on webfaction

    Choose memcached from custom install scripts and set extra info to maximum number of MB (eg 2)

    This executes:
    memcached start -d -l 127.0.0.1 -m 5 -P $PWD/memcached.pid -p XXXXX

    Then can access with gluon.contrib.memcache

    Take note of port used

    Tuesday, March 16, 2010

    Komodo

    Run current file with Python: %(python) "%F"