Archive

Archive for March, 2009

Software raid voume won’t start after reboot.

March 18th, 2009

ubuntu@ubuntu:/mnt$ sudo mount -t ext3 /dev/md0 /mnt/md0

mount: wrong fs type, bad option, bad superblock on /dev/md0,
missing codepage or other error
(could this be the IDE device where you in fact use
ide-scsi so that sr0 or sda or so is needed?)
In some cases useful info is found in syslog - try
dmesg | tail  or so


$ sudo mdadm –assemble /dev/md0 /dev/sdd /dev/sdb /dev/sdc
mdadm: /dev/md0 has been started with 3 drives.

$sudo mount /dev/md0 /data/

OR….

Simply run this command.

mdadm --detail --scan >> /etc/mdadm/mdadm.conf

Mount again and all should work!

Uncategorized

Python: Escaping input for db insertion

March 16th, 2009
import MySQLdb
data="jeremiah's new laptop"
data=MySQLdb.escape_string(data)
cursor.execut("INSERT INTO table1 name VALUES (data);")

Python

Python: Get hostname

March 11th, 2009
import sys, socket

hostname = socket.gethostname()
print "Host name:", hostname

Uncategorized

Access MySQL from Python

March 10th, 2009
import MySQLdb #python-mysqldb
conn = MySQLdb.connect (host = "localhost", user = "root", passwd = mysql_pass, db = "")
cursor = conn.cursor ()
cursor.execute("use database")

Python

How to parse a CVS File : Python

March 10th, 2009
#!/usr/bin/python
import csv
import MySQLdb

spamReader = csv.reader(open('eggs.csv'), delimiter=' ', quotechar='|')
for row in spamReader:
print ' '.join(row)

Python

Create ISO in Linux

March 9th, 2009

To create an image (link to a more verbose explanation) use dd on an unmounted CD/DVD drive:
dd if=/dev/cd of=cd.iso

Uncategorized

Create Linux Command Aliases

March 5th, 2009

add command to the bottom of the .bashrc file

alias cvsu='cvs -q update -P -d'

$source ~/.bashrc

now run the new command
$ cvsu

Uncategorized

Right justifying numbers

March 5th, 2009

When displaying numbers on a web page make sure that you right justify the data for use of decimals.

For example, if left justifying data your table will look like this…

100.50
324.34
.25
5.34

When right justified it looks better and your decimals line up.

100.00
.25
5.67

Linux