Monday, June 15, 2009

Python basics : math functions, main funct

Math functions
#Unfortunately, you need to import math, but python has a nice library of math functions



import math
math.pow(2,3)
math.cos(math.pi/2) #<-- radians!
math.pi
math.sqrt(4)



Main function

#Making a main function in Python is a little tricky. Here is an example:



def main(*args):
if len(args) < 4:
return

print "main : args[0] ", args[0], " args[1]", args[1]
print "(main) : args[1] ", args[2]
print "(main) : args[3] ", args[3]

if __name__ == "__main__":


Sunday, June 14, 2009

Mysql -- get table engine type

Get table engine type

You have to go to the mysql system database 1st

This allows you to see which type of table engine you're using

Common types:

myisam: doesn't support the features listed below for innodb
innodb (default) : supports r-trees (good for spatial extensions), enforces foreign keys, and supports transactions


select table_name, engine from tables where table_schema = "vsn";

Thursday, June 11, 2009

Checking versions if Office 2004 is at 11.5.5 and Acrobat is at 9.1.2

This is a trick to check version of some software on a group of computers


Here we're checking that Office 2004 11.5.5 update is installed


for ((i=1;i < 21;i++)); do if [[ $i -lt 10 ]]; then echo "station $i" ; ssh station-0${i}.local " ls -l /Applications/Microsoft\ Office\ 2004/Updater\ Logs/11.5.5\ Update\ Log.txt "; else ssh station-${i}.local " ls -l /Applications/Microsoft\ Office\ 2004/Updater\ Logs/11.5.5\ Update\ Log.txt "; fi; done

Here we're checking that Acrobat reader and acrobat are at 9.1.2


for ((i=1;i < 21;i++)); do if [[ $i -lt 10 ]]; then echo "station $i" ; ssh station-0${i}.local "system_profiler SPSoftwareDataType SPApplicationsDataType | grep '9.1.2' "; else ssh station-${i}.local " system_profiler SPSoftwareDataType SPApplicationsDataType | grep '9.1.2' "; fi; done

Wednesday, June 10, 2009

How to set up Jogre for the web

Set up jdk, apache tomcat, and hsqldb
==============================

apt-get install sun-java6-jdk
apt-get install tomcat5.5 tomcat5.5-wepapps tomcat5.5-admin
apt-get install hsqldb-server

Set up jogre
=========

wget http://voxel.dl.sourceforge.net/sourceforge/jogre/jogre_beta_0.3_bin.zip
cd /opt
unzip ~/jogre_beta_0.3.bin.zip
adduser jogre
chown -R jogre:jogre jogre
su jogre
cd
echo "export CLASSPATH=$CLASSPATH:/usr/share/java/hsqldb.jar:." >> .profile
source .profile
java org.hsqldb.Server &
cd /opt/jogre/server
chmod a+x *.sh


Configuration
==========

./server.sh &

#I prefer the gui; it's easier to just change the db settings with this tool
./administrator.sh &
#Login with admin, admin
#Change the database from xml to hsqldb
#The path to the db is jdbc:hsqldb:hsql://localhost/jogre_hsqldb

#restart the jogre server
killall server.sh
./server.sh &


#With apache tomcat admin (http://localhost:8180/admin), add jogreweb.war

Tuesday, June 9, 2009

How to start another X session

You already have X running and want to run another one.

1. Login into another virtual console
2. Open the terminal
3. startx -- :1

Monday, June 8, 2009

Tricks with the Echo command in XP

rem generate list with echo
for /l %a in (1,1,9) do echo "station-0%a"

rem Generate a file with echo to a room of computers
for /l %a in (1,1,50) do echo "station-%a" > \\station-%a\c$\myfile.txt