Record of some of the computer tech I deal with so that it's documented at least somewhere.

Tuesday, 24 March 2009

more trig

for a half circle

for a point X, Y

if X < w / 2

x = ( w / 2 ) - X

a = atan(y / x)
R = sqrt(x * x + h * h)
scale = h / R

Monday, 23 March 2009

Projection trig

the throw ratio (R) is defined as distance to screen (D) divided by the width of the image (W)

or rather R = D / W
As we normally have R, are constrained by D and want to know W rewrite that as

W = D / R

if we assume D = 1 then W = 1 / R
for atan we only use half the triangle for the angle from straight :
thus
a = atan (W / 2) = atan ( (1 / R) * (1 / 2) ) = atan ( 1 / 2R )
ergo the angle of the cone A = 2 * a = 2 * atan ( 1 / 2R )
for a Ratio of 0.8, A = 2 * atan( 1 / 1.6) = 64.011 degrees

mpeg2enc & dvdauthoring on debian

basically you have to install
http://debian-multimedia.org/

apt-get install mjpegtools mkisofs dvdauthor ffmpeg

2mpeg

#!/usr/local/plan9/bin/rc

f = 8 # for dvdauthor otherwise go with 3
br = 7500
a = 3
q = 5

while(~ $1 -*) {
switch($1) {
case -b
br = $2
shift 2
case -f
f = $2
shift 2
case -a
a = $2
shift 2
# 1 - 1 - 1:1 display
# 2 - 2 - 4:3 display
# 3 - 3 - 16:9 display
# 4 - 4 - 2.21:1 display
case -i
deinterlace = '-deinterlace'
shift
case -q
q = $2
shift 2
}
}

paff = $1
shift
fname = `{basename $paff}

2mp2 $paff &
2m2v -q $q -a $a -f $f -b $br $paff $deinterlace &
wait

mplex -f 8 -o $fname.mpeg $fname.m2v $fname.mp2 && rm $fname.m2v $fname.mp2


2mp2

#!/usr/local/plan9/bin/rc

mplayer -vc null -vo null -ao 'pcm:fast:file=' ^$1.wav $1
mp2enc < $1.wav -o `{basename $1} ^.mp2 && rm $1.wav


2wav

#!/usr/local/plan9/bin/rc

aid = ''
while(~ $1 -*) {
switch($1) {
case -aid
aid = '-aid ' $2
shift 2
}
}

mplayer $aid -vc null -vo null -ao 'pcm:fast:file=/dev/fd/1' -

make some mpegs : 2mpeg 1.mov
2mpeg 2.mov
so you'll end up with 1.mov.mpeg 2.mov.mpeg
ffmpeg can deduce your aspect if you don't want to specify it
then make an xml (dvd.xml) file thus :

<dvdauthor dest="dvd">
<vmgm />
<titleset>
<titles>
<video format="pal" aspect="4:3" />
<audio format="pcm" lang="EN" />
<subpicture lang="EN" />
<pgc>
<vob file="1.mov.mpeg" />
<vob file="2.mov.mpeg" />
</pgc>
</titles>
</titleset>
</dvdauthor>


then


dvdauthor -x dvd.xml
mkisofs -dvd-video -udf -o dvd.iso dvd
wodim dev=/dev/cdrw1 -dao dvd.iso


done

Tuesday, 17 March 2009

Mplayer OSX - working

Anothy_x reminded me about MacPorts

yay, mplayer working

except .... getting it to run at boot. putting it in login_items you have to associate it with terminal and then the mouse being in the top left means the mplayer menu bar is across the top.

yay, done it. The power of Java moving the mouse off screen

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;

public class RM {
public static void main(String[] args) {
try {
Robot robot = new Robot();
robot.delay(5000);
robot.mouseMove(100, 10000);
} catch (AWTException e) {
e.printStackTrace();
}
}
}

I presume the class file has to be in the classpath, Looks like that includes .

#!/bin/bash
cd /Users/broadway/bin
java RM RM.class
mplayer -playlist /Users/broadway/media/playlist


Yay, remove the bullet and sew up the wound; I'm out of this crazy hospital.

Monday, 16 March 2009

Mplayer OSX

Adapted from http://jonsimpson.co.uk/log/2005/mplayer_cvs_osx_tiger
FAIL

shoot me

sshd on MacMini / OSX 10.4.11

On the machine I got control of there were no ssh keys

nothing unusual going on, keys are in /etc instead of /etc/ssh

ssh-keygen -t rsa1 -q -f /etc/ssh_host_key
ssh-keygen -t rsa -q -f /etc/ssh_host_rsa_key
ssh-keygen -t dsa -q -f /etc/ssh_host_dsa_key

/usr/sbin/sshd

getting it to startup on boot - Preferences - Network - Remote Access [x]

I suspect that it would have generated the proper keys if I'd done that first !

Wednesday, 11 March 2009

Building p9p from hg

FAIL

I spend more time setting up the environment than doing the damn work when I get there!
There was once a golden age where I could say to someone "I need a machine with Apache and Postgresql and CGI enabled for a domain foo.com" and they would email me when it was working. Happy days, but nothing to blog about!

Ok so now I have a plan9port from Mercurial and it doesn't have some cmds built like awk and others I've not even looked at.

First off is I can't build the awk because I don't have mk and I can't build mk because I don't have mk!

Luckily VitaNuova have their source tree available and for the moment the source tree is this file but it is referenced by date.

To make it work you have to unpack it in /usr and then I couldn't build it anyway. Aha but mk is in /usr/inferno/Linux/386/bin/mk and runs so I copied it to /usr/local/bin/mk

cd /usr/local/plan9/src/cmd/awk
which now fails with
warning: skipping missing include file: /src/mkhdr: No such file or directory
warning: skipping missing include file: /src/mkone: No such file or directory

because of <$PLAN9/src/mkhdr
even if $PLAN9 is set so the solution is PLAN9=$PLAN9 mk
but more joy

9 yacc -S -d -v awkgram.y
/usr/local/plan9/bin/9: line 17: exec: yacc: not found
mk: 9 yacc -S ... : exit status=exit(127)

again
cp /usr/inferno/Linux/386/bin/yacc /usr/local/bin/

PLAN9=$PLAN9 mk
9 yacc -S -d -v awkgram.y

conflicts: 42 shift/reduce, 83 reduce/reduce
9c re.c
9c lex.c
9c main.c
9c parse.c
9c maketab.c
9c tran.c
9c lib.c
9c run.c
9c y.tab.c
9l -o o.maketab maketab.o
/usr/bin/ld: cannot find -l9
collect2: ld returned 1 exit status
mk: 9l -o o.maketab maketab.o : exit status=exit(1)



time to download http://swtch.com/plan9port/plan9port.tgz ! and

apt-get install xorg-dev
Need to get 14.7MB of archives.
After this operation, 47.5MB of additional disk space will be used.
Do you want to continue [Y/n]? y

Monday, 9 March 2009

Working the Werc

I'm giving Werc a try out, I hope the fella's done a good job.

First shizzle I need is an hg client do get a checkout, I notice there's a lot of checkins so it's better this way I reckon. Plus I'll be a contributor before long.

Hg only needs 16.8Mb of files !! hgsvn is the package name - hope it's the right one.

slap:/var/www# rmdir werc
slap:/var/www# hg clone http://gsoc.cat-v.org/hg/werc/

ok that worked out

lighttpd.conf

need to add "mod_cgi", to the modules section or run : lighty-enable-mod cgi

$HTTP["host"] =~ ".*feedideas.$" {
index-file.names = ( )
server.error-handler-404 = "/werc.rc"
alias.url += ( "/werc.rc" => "/var/www/werc/bin/werc.rc" ) # Here use the path to werc.rc in your system.
cgi.assign += ( ".rc" => "")
server.dir-listing = "disable"
}


Then mkdir /var/www/werc/sites/feedideas
echo HelloWorld > /var/www/werc/sites/feedideas/index.html
/etc/init.d/lighttpd restart


Then you can begin the task of skinning your website so it doesn't look like the paedophile cat-v ;)

Apparently werc utilizes markdown but when I tried it, I got literals.

Not totally happy with the directory structure but been working with Uriel on moving a few functions around so you can overload your own.

Tuesday, 3 March 2009

O, that way madness lies.

Thanks Skip for the title.

#include <u.h>
#include <libc.h>
#include <draw.h>
#include <cursor.h>

Image *col[2];

void
main(void) {
Point zero;
zero.x = 0;
zero.y = 0;

newwindow("-r 0 0 700 300");
if(initdraw(nil, nil, "tri") < 0){
fprint(2, "stats: initdraw failed: %r\n");
exits("initdraw");
}

/* code in the boxes goes here */
col[0] = allocimage(display, Rect(0,0,1,1), RGB24, 1, setalpha(0xFF0000FF, 0xFF));
col[1] = allocimage(display, Rect(0,0,1,1), RGB24, 1, setalpha(0x00FF00FF, 0xFF));
draw(screen, screen->r, col[0], nil, zero);
draw(screen, Rect(0,0,350,150), col[1], nil, zero);
/* to here */

flushimage(display, 1);
sleep(10000);
closedisplay(display);
}


This is the image with no alpha



As expected, apply alpha to the red or the green and the intensity diminishes. No blending.





But with RGB24 you can't do Porter-Duff operations. But when you apply alpha to RGBA32 images something unexpected happens :




I can't work out how that transformation even occurs - The green turns to fd007f, the red to 7f80ff. Where does the blue come from?

If I drawop them too I get :



Green = bd40ff
Red = 7f80ff

I'm afraid it defies my comprehension!

Monday, 2 March 2009

serving 9p from debian

Despite a tried and tested u9fs working, I went the npfs route.

No docs.

I prefer tcpserver over inetd so # apt-get install ucspi-tcp

naively I tried slap:/home/maht/spfs# tcpserver -v 10.0.0.1 564 fs/ufs

mount failed : Hangup

back to u9fs, cba pissing about
can't find a download for u9fs at sourceforge - though I can find the cvs browser so I uploaded it to my webspace

once you've built u9fs with make

cp u9fs /usr/local/bin/u9fs-bin
touch /usr/local/bin/u9fs
ed /usr/local/bin/u9fs
a
#!/bin/sh

u9fs-bin -a none
.
w
q

tcpserver 10.0.0.1 564 u9fs

and away you go
(you'll need your plan9 users as users on Debian and you trust the names)

so you could use -a p9any and use /etc/u9fs.key
I'll check it works in a bit when my 4Gb has finished copying - nope failed for me - giving up

time cp linux /n/slap/home/glenda
0.88u 105.31s 2176.35r cp linux /n/slap/home/glenda


which is 36.26 mins

Installing Debian 5 to AoE

before you copy this procedure, the initrd.aoe didn't work out, I've got to inspect it an compare it against the one that worked for etch



haha found aoe.ko on the install disk
on the vblade server aptitude vblade

dd if=/dev/zero of=lenny bs=1048576 count=4096
vblade 3 1 eth0 lenny
dd if=/dev/zero of=home bs=1024 count=204800
vblade 3 2 eth0 home
dd if=/dev/zero of=swap bs=1024 count=204800
vblade 3 3 eth0 swap


run the installer until you can get a shell (alt-f2)
which for me was "configure the network"



udpkg --unpack /cdrom/pool/main/l/linux-2.6/linux-image-2.6.26-1-486_2.6.26-13_i386.deb
insmod /lib/modules/2.6.26-1-486/kernel/drivers/block/aoe/aoe.ko

cd /dev
ln -s /dev/etherd/e3.1 hda
ln -s /dev/etherd/e3.2 hdb
ln -s /dev/etherd/e3.3 hdd



The installer will moan that it can't install GRUB and give you the choice to skip along, do that.
Eventually you get "Installation is complete" and a
choice.

Now it's hack time. Crack open the initrd.img the installer just made

chroot /target
mkdir /tmp/initrd && cd /tmp/initrd
gunzip < /initrd.img | cpio -i --make-directories


I got the scripts from http://www.etherboot.org/wiki/sanboot/debian_and_ubuntu

apt-get install aoetools
cp /sbin/aoe-discover /tmp/initrd/sbin/
cd /etc/initramfs-tools/
wget http://www.proweb.co.uk/~matt/aoe/hooks -O hooks/aoetools
wget http://www.proweb.co.uk/~matt/aoe/scripts -O scripts/aoetools
chmod 755 hooks/aoetools scripts/aoetools
cp scripts/aoetools /tmp/initrd/scripts/


Then make the initrd.img again

cd /tmp/initrd
find . | cpio -o -H newc | gzip -9 > /boot/initrd.aoe



Then get it off the machine and on to the TFTP server.
scp /boot/initrd.aoe /boot/vmlinuz-2.6.6.26-1.686 TFTP-server:/var/lib/tftpboot/

Now to taste the pudding