Pages

Saturday, November 28, 2009

Linux memory i386 vs x86_64

http://kerneltrap.org/node/2450

http://www.linuxforums.org/forum/linux-tutorials-howtos-reference-material/69585-should-you-choose-32-bit-64-bit-linux.html

http://en.wikipedia.org/wiki/64-bit#Pros_and_cons

Slow wireless on windows 7

http://social.answers.microsoft.com/Forums/en-US/w7hardware/thread/cd9cf085-8963-4530-9471-d6aeca82b324

Friday, November 27, 2009

Website backup script

This script has many issues. The biggest is that it is dumping xml from mysql. There currently is not a good restoration path from an xml export.

I'll be updating this script using svn for versions and a one insert per line mysqldump for more effective diffs.



#!/ramdisk/bin/bash

function updateCurrent(){
linkcurrent=$1
newfile=$2

if [ -h ${linkcurrent} ] ; then
linktarget=`/usr/bin/readlink ${linkcurrent}`

rm ${linkcurrent}

if [ -e ${linktarget} ] && diff ${linktarget} ${newfile} > /dev/null; then
rm -rf ${linktarget}
fi
fi

ln -s ${newfile} ${linkcurrent}
}

dts=`/bin/date +\%Y\%m\%d\%H\%M\%S`
currentSqlLink='/path/to/home/tmp/sqlCurrent'
currentTarLink='/path/to/home/tmp/tgzCurrent'

newSql="/path/to/home/backups/uniquieName-${dts}"
newTar="/path/to/home/backups/emz-${dts}"

mysqldump -X --user=db_user --password=secret --skip-dump-date --host=127.0.0.1 db_name > $newSql
updateCurrent ${currentSqlLink} ${newSql}

tar -cf ${newTar} /path/to/home/web_root/
updateCurrent ${currentTarLink} ${newTar}


Monday, November 23, 2009

Convert a resume to a fixed width mono space font



#!/usr/bin/perl

open(FP, "sr.txt");

@buffer=();
$maxFJ = 0;

while(<FP>){
chomp();
while(/^ *\t/){
s/\t/ /;
}
if(/\S\s{2,}\S/){
s/(\S)\s{2,}/$1\|/g;

if(length($_) > $maxFJ){
$maxFJ = length($_);
}
}
push(@buffer, $_);
}
# print "$maxFJ\n";
$maxFJsmaller = $maxFJ - 14;

for($x=0; $x<$maxFJ; $x++){
$separ .= "=";
}
$separ .= "\n";

foreach $line (@buffer){

#print "$separ";

# determine indent
$prefix='';
if($line =~ /^(\s*)\S/){
$prefix = $1;
}

if($line =~ /(.*)\|(.*)/){
$midPad=' ';
for($x = length($line); $x < $maxFJ; $x++){
$midPad .= ' ';
}
$line = "$1$midPad$2";
}else{
# word wrap
while($line =~ s/(.{$maxFJsmaller}[^\s]*)\s(\s*)/$prefix$2/){
print "$1\n";
}
}

print "$line\n";
}


Sunday, November 15, 2009

Blogger Paste

http://francois.schnell.free.fr/tools/BloggerPaste/BloggerPaste.html

Paste your code into a blogger post. Looking for something similar with code highlighting.

Script to move mythtv files to another server



#!/usr/bin/perl

open(FP, "<ma");

$cmd = '-t';

if($#ARGV>0){
print "too many arguments\n";
print useage();
exit();
}elsif($#ARGV==0){
if($ARGV[0] eq '-t' || $ARGV[0] eq '-l' || $ARGV[0] eq '-d' || $ARGV[0] eq '-dd'){
$cmd = $ARGV[0];
}else{
print useage();
exit();
}
}

@filenames=();
while(<FP>){
chomp();
@video = split(/\|/);
$title = quotemeta(trim($video[2])) . ".mpg";
$basename = trim($video[1]);

if($cmd eq '-t'){
print "ln $basename xfer/$title \n";
print "rm $basename*\n";
}elsif($cmd eq '-l'){
`ln $basename xfer/$title`;
}elsif($cmd eq '-d'){
`rm $basename*`;
}elsif($cmd eq '-dd'){
push(@filenames, $basename);
}
}
if($cmd eq '-dd'){
print "delete from recorded where basename in (\n";

$first = 0;
foreach $file (@filenames){
print " " . ($first++?',':'') . "'$file'\n";
}
print ");\n";
}

# Perl trim function to remove whitespace from the start and end of the string
sub trim($) {
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
# Left trim function to remove leading whitespace
sub ltrim($) {
my $string = shift;
$string =~ s/^\s+//;
return $string;
}
# Right trim function to remove trailing whitespace
sub rtrim($) {
my $string = shift;
$string =~ s/\s+$//;
return $string;
}

sub useage{
print "The file ma contains a list of files from the following query\n";
print " select basename, title, filesize from recorded order by filesize, title;\n\n";
print "Create a folder called xfer\n\n";
print "-h for help\n";
print "-t test run (just print link statements\n";
print "-l create links\n";
print "-d delete original files\n";
print "-dd database delete command\n";
}


Sunday, November 8, 2009

NFS for MAC to VM

Need to refine this when installing a fresh Fedora Core VM

The thing I always forget is to export the changes to allow the shares to operate
exportfs -ra

/etc/exports
/share 192.168.56.0/255.255.255(rw,root_squash,insecure,sync)

/etc/hosts.allow
portmap: 192.168.56.0/255.255.255.0
lockd: 192.168.56.0/255.255.255.0
rqotad: 192.168.56.0/255.255.255.0
mountd: 192.168.56.0/255.255.255.0
statd: 192.168.56.0/255.255.255.0

/etc/hosts.deny
portmap: ALL
lockd: ALL
rqotad: ALL
mountd: ALL
statd: ALL

After creating the share, touch a file and create a user/group to match whatever linux produces. I would eventually like to be able to made the connection use a particular user/group.

Reference

Saturday, November 7, 2009

Php: filter assoc data array

Need to code test
<?php
$data['id'] = 1;
$data['name'] = 'bob;

$filterKeys = array('name');

$dataFiltered = array_intersection_key($data, array_flip($filterKeys));

Friday, November 6, 2009

Electric Bike References

http://www.youtube.com/watch?v=OC80RKJ771M&feature=PlayList&p=42F30EBA52CCFA78&index=16

http://www.bikesatwork.com/hauling-cargo-by-bike/how-to-measure-grade.html

http://www.electricrider.com
http://www.cycle9.com
http://www.bicycle-power.com/diykits.html
http://www.electric-bikes.com/betterbikes/bmc.html (9lbs)
http://e-bikekit.com
http://www.jvbike.com/crystalyte.htm
http://ampedbikes.com
http://www.e-bikekit.com/shop/index.php
http://www.electric-bikes.com/buying/index.html
http://www.greenspeed.us/
http://www.falconev.com
http://www.electric-bikes.com

http://en.wikipedia.org/wiki/Bicycle_performance
http://www.convertunits.com/from/watt/to/newton+meter/second
http://www.onlineconversion.com/forum/forum_1011109627.htm
http://www.ap.smu.ca/demonstrations/index.php?option=com_content&view=article&id=80&Itemid=85
http://www.physicsclassroom.com/class/newtlaws/u2l2c.cfm
http://www.macgen.com/calcul.html

http://www.forsenusa.com/batteries.html