ACPI is n/a for ppc. Same for apm. Those don't work with the ppc hardware. Pbbuttonsd controls sleep and hibernate. And for PPC Linux, you must have an ATI graphics card for sleep to work. Nvidia and anything else will not work.
$ sudo pbbcmd hibernate
or
$ sudo pbbcmd sleep
or
$ sudo pbbuttonsd sleep
or
$ sudo pbbuttonsd hibernate
Friday, May 14, 2010
Sunday, April 18, 2010
Python - test urlopen function
import urllib
f = urllib.urlopen("http://www.google.com")
print f.read()
Monday, April 5, 2010
Flash Card to Moodle xml
#example flashcard questions:
Which switch would you use with the echo command to enable the "backslash" options? ------ -e
Which switch would you use with the find utility to cause another command to run without prompting you? ------ -exec
Which switch would you use with the echo command to enable the "backslash" options? ------ -e
Which switch would you use with the find utility to cause another command to run without prompting you? ------ -exec
#shell script
#!/bin/sh
converted="converted.xml"
sep="------"
if [[ $# -ne 1 ]]
then
echo "$0 file_to_convert"
exit 1
fi
echo "starting conversion to moodle xml"
if [[ -f $converted ]]
then
echo "$converted already exists"
rm $converted
fi
echo '<?xml version="1.0" ?>' > $converted
echo "<quiz>" >> $converted
i=1
cat $1 | while read line
do
q=`echo $line | awk -F"$sep" '{ print $1 }'`
a=`echo $line | awk -F"$sep" '{ print $2 }'`
echo '<question type="shortanswer">' >> $converted
echo '<name>' >> $converted
echo "<text>Question $i</text>" >> $converted
echo '</name>' >> $converted
echo '<questiontext format="html">' >> $converted
echo "<text>$q</text>" >> $converted
echo '</questiontext>' >> $converted
echo '<answer fraction = "100">' >> $converted
echo "<text>$a</text>" >> $converted
echo '<feedback><text>Correct!</text></feedback>' >>$converted
echo '</answer>' >> $converted
echo '</question>' >> $converted
((i=i+1))
done
echo '</quiz>' >> $converted
Tuesday, March 30, 2010
Linux - wireless commands
wireless commands
iwlist wlan0 scan
wevent &
iwconfig wlan0 key open xxxxx
iwconfig wlan0 essid xxxx
iwlist wlan0 scan
wevent &
iwconfig wlan0 key open xxxxx
iwconfig wlan0 essid xxxx
Wednesday, March 17, 2010
Set program output to environment variable in batch file
FOR /F "tokens=*" %A IN ('prog.exe') DO SET ENVVAR=%A
gcc, gdb and make commands
Macro definition
gcc -D DUMMY_DEF -c test_str.c
Makefile arguments
test:
./program $(PROG_ARGS)
make test PROG_ARGS='testfile1.txt'
gdb commands
run args - runs program
frame - examines current frame
up - examines previous frame
gcc -D DUMMY_DEF -c test_str.c
Makefile arguments
test:
./program $(PROG_ARGS)
make test PROG_ARGS='testfile1.txt'
gdb commands
run args - runs program
frame - examines current frame
up - examines previous frame
Wednesday, February 24, 2010
Sunday, January 24, 2010
Mortgage calculator - bash script
This simply outputs the monthly mortgage payment.
Takes five arguments : principle years interest points fees
For instance,
bash mortgage.sh 100000 5 .075 0 0
Outputs
Principle + fees = 100000 , Years = 5 , Months = 60 , interest .006250000000
Points = 0 , 0
2003.794859563881
Takes five arguments : principle years interest points fees
For instance,
bash mortgage.sh 100000 5 .075 0 0
Outputs
Principle + fees = 100000 , Years = 5 , Months = 60 , interest .006250000000
Points = 0 , 0
2003.794859563881
#!/bin/sh
if [[ $# -ne 5 ]]
then
echo "enter 5 args : principle years interest points fees"
exit
fi
prin=$1
((mon=$2 * 12 ))
inter=`echo "scale=12;$3/12" | bc`
pts=`echo "scale=12; $prin * $4" | bc`
fee=$5
prin=`echo "scale=12;$prin + $fee" | bc`
echo "Principle + fees = $prin , Years = $2 , Months = $mon , interest $inter"
echo "Points = $4 , $pts"
prin=`echo "scale=12; $prin - $pts" | bc`
echo `echo "scale=12;($prin*$inter)*((1+$inter)^$mon)/(((1+$inter)^$mon)-1)"|bc`
echo "the monthly payment : $new_prin"
Sunday, January 17, 2010
start menu pin list location
> If I pin a shortcut to the startmenu, where does XP store this
> information?
With a shortcut in this folder...
C:\Documents and Settings\All Users\Start Menu
The above folder would be the easiest.
Also here...
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Explorer\MenuOrder\Start Menu2\Programs
Value Name: Order
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Explorer\StartPage
Value Name: Favorites
Value Name: FavoritesResolve
All of those are REG_BINARY values and hard to read them.
Monday, January 11, 2010
Bash - Gaussian Elimination Op count example
#!/bin/sh
if [[ $# -ne 2 ]]
then
exit
fi
echo " m $1 by n $2 matrix"
n=$2
m=$1
mult=0
add=0
c=0
for ((i=1;i < m;i++))
do
echo "row = i = $i"
for ((j=i;j < m;j++))
do
((mult=mult + (n-i+1)))
((add=add + (n-i+1)))
done
((c=c+(m-i)*(n-i+1)))
done
echo "additions = $add"
echo "mults = $mult"
echo "summation = $c"
Matlab - simple newton's method ex
function r = doNewton(f,x0,x,err)
while abs(x0 - x) > err
x0, (x0 - x)
x0 = x0 - (polyval(f,x0))/polyval(polyder(f),x0);
end
r = x0;
end
Subscribe to:
Posts (Atom)