Pages

Sunday, December 27, 2009

SETUP OF NEW MythBuntu 9.10 x86

Rev D3A Media MediaMVP (non-flash; older)


https://help.ubuntu.com/community/MythTV/MediaMVP_Frontend

http://mvpmc.sourceforge.net/mvpmc-HOWTO-singlehtml.html


Added  before the exit 0 in /etc/rc.local

/usr/sbin/atftpd --daemon --port 16869 --retry-timeout 120 \

--mcast-addr 192.168.1.0-255 --mcast-ttl 2 --verbose=7 /tftpboot

/usr/sbin/atftpd --daemon --port 69


Disabled DHCP on my Cable/DSL router


apt-get install atftpd dhcp3-server xinetd


Added the following to the /etc/dhcp3/dhcpd.conf

INTERFACES="eth0";


option domain-name              "local";

option subnet-mask              255.255.255.0;

option domain-name-servers 192.168.1.1;


allow bootp;

allow booting;


#option ip-forwarding    false;  # No IP forwarding

#option mask-supplier    false;  # Don't respond to ICMP Mask req


subnet 192.168.1.0 netmask 255.255.255.0 {

  option routers        192.168.1.1;

  range 192.168.1.12 192.168.1.25;

}


group {

  next-server 192.168.1.3;          # IP address of your TFTP server


  host mvp1 { # NOTE: Change the hardware ethernet to the MAC address of your actual MVP

           hardware ethernet 00:0d:fe:xx:xx:xx;

           fixed-address 192.168.1.31;

           filename "dongle.bin";

           option root-path "/home/mvp,rsize=4096,wsize=4096,nolock";

  }

  host mvp2 { # NOTE: Change the hardware ethernet to the MAC address of your actual MVP

           hardware ethernet 00:0d:fe:xx:xx:xx;

           fixed-address 192.168.1.32;

           filename "dongle.bin";

           option root-path "/home/mvp,rsize=4096,wsize=4096,nolock";

  }


}


wget http://downloads.sourceforge.net/project/mvpmc/mvpmc/mvpmc-0.3.4/dongle.bin.mvpmc-0.3.4?use_mirror=iweb


dongle.bin.config

export TZ="MST+7MDT"

/bin/ntpclient -s -h us.pool.ntp.org

mkdir /aRecordings

mkdir -p /var/lib/mythtv/old-recordings

mkdir -p /var/lib/mythtv/recordings

mount -t nfs -o nolock,rsize=2048,wsize=2048,nfsvers=3 192.168.1.2:/var/lib/mythtv/link-share /aRecordings

mount -t nfs -o nolock,rsize=2048,wsize=2048,nfsvers=3 192.168.1.2:/var/lib/mythtv/old-recordings /var/lib/mythtv/old-recordings

mount -t nfs -o nolock,rsize=2048,wsize=2048,nfsvers=3 192.168.1.2:/var/lib/mythtv/recordings /var/lib/mythtv/recordings

mvpmc &


Edit /etc/exports on the myth backend; do not forget to run exportfs -ra after you modify the nfs configuration.

 

Mythbuntu-- mysql root password is the password of the account used to setup the mythbuntu install


crontab on root for mythfilldatabase

crontab on mythtv to create symlinks in the link-share folder (see the script in the article: Mythtv Php Script to Create Symlinks with Titles)


Hubzone Businesses

I don't know much about Hubzones, but what I do know is that government contracting officers get huge credits by using hub zone businesses. I did a quick search using the search link below. Looks like there are only about 16 registered hubzone businesses in El Paso country. If I understand things correctly, of the main conditions is the location of the business. You can zoom in on Colorado Springs using the map link below.


Mythtv Php Script to Create Symlinks with Titles

<?php
###
### CREATE Database file to title lookup
###

$link = mysql_connect('localhost', 'mythtv', 'db_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$db = mysql_select_db("mythconverg",$link);
if (!$db) {
    die ('Can\'t use mythconverg : ' . mysql_error());
}

$titleLookup = array();

$result = mysql_query("select title, basename from recorded");

while ($row = mysql_fetch_array($result)) {
    $title = $row["title"];
    $titleLookup[$row["basename"]] = $title;
}
mysql_free_result($result);

mysql_close($link);

###
### Create symbolic links
###

$srcBaseFolder = "/var/lib/mythtv/recordings/";
$destBaseFolder = "/var/lib/mythtv/link-share/";

if ($handle = opendir($srcBaseFolder)) {

   while (false !== ($file = readdir($handle))) {

      if ( preg_match('/\.mpg$/', $file) ) {
          $src = $srcBaseFolder . $file;
          $destBase = $destBaseFolder . $titleLookup[$file];
          $dest = $destBase . ".mpg";

          $x = 0;
          while( file_exists($dest) ){
              if( basename(readlink($dest)) == basename($src) ){
                  break;
              }
              $dest = $destBase . "-" . ++$x . ".mpg";
          }
    
          if( !file_exists($dest) ){
              symlink( $src, $dest );
          }
       }
   }

   closedir($handle);
}

###
### Remove bad links
###

if ($handle = opendir($destBaseFolder)) {

   while (false !== ($file = readdir($handle))) {

      $file = $destBaseFolder . $file;

      if ( is_link($file) ) {
          if( !file_exists( readlink($file) ) ){
             unlink($file);
          }
      }
   }

   closedir($handle);
}


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