|
Map drives after connect to home WiFI |
|
I use NetworkManager to connect to my wireless network and wanted a way to map the drives automagically when I connect. However, as I connect to a number of wireless access points I didn't want to send my credentials trying to find my home server out each time I connect at the coffee shop. Enter the NetworkManager dispatcher. Scripts in /etc/NetworkManager/dispatcher.d/ are executed when the network manager connection is made. I created the following file as "99mountmydrives" and chmodded it with execute permissions. See the script below: #!/bin/sh
IF=$1 STATUS=$2 USER=myusername SERVERIP=192.168.1.200 SERVERMAC=00:aa:bb:cc:dd:ee
echo "running 99mountmydrives as `whoami`;" >> /tmp/dispatcher-log echo "int=$1 and status=$2" >> /tmp/dispatcher-log
wait_for_process() { PNAME=$1 PID=`/usr/bin/pgrep $PNAME` while [ -z "$PID" ]; do echo "waiting." >> /tmp/dispatcher-log sleep 3; PID=`/usr/bin/pgrep $PNAME` done }
mount_drives() { echo "waiting for nm-applet" >> /tmp/dispatcher-log wait_for_process nm-applet echo "mounting drives" >> /tmp/dispatcher-log /home/mvoorberg/automountmyth.sh }
if [ "$IF" = "wlan0" ] && [ "$STATUS" = "up" ]; then #WIFI Subnet at home
test=`ping -c 3 $SERVERIP >/dev/null;arp -a $SERVERIP` echo "$test" >> /tmp/dispatcher-log
if expr "$test" : ".*$SERVERMAC" 2> /dev/null ; then mount_drives exit $? fi fi
|
|
Last Updated ( Thursday, 02 December 2010 )
|
Discuss this item on the forums. (0 posts)
|
|
Convert RAW to Jpeg on Ubuntu |
|
You'll need to install a few packages before this works: sudo apt-get install netpbm sudo apt-get install dcraw
Once you've got these installed, put the following in a file in ~/.gnome2/nautilus-scripts/ and restart Nautilus to add it to the right-click context menu. #!/bin/bash files=$# count=1 message=`echo "Converting $files RAW files to Jpeg"`
(while [ $# -gt 0 ]; do
upperExt=`echo $1 | sed 's/.*\(\..*\)/\1/' | tr '[a-z]' '[A-Z]'` if [ $upperExt = ".CR2" -a -f $1 ] then trimmed=`echo $1 | sed 's/\(.*\)\..*/\1/'` dcraw -c -w -h -b 1.0 "$1" | ppmtojpeg > "$trimmed.jpg" fi # Output the zenity progress bar sav=`echo "(($count / $files) * 100)" | bc -l` echo $sav count=`expr $count + 1` shift done) | zenity --progress --auto-close --auto-kill --text "$message"
You'll have to make the file executable by using: chmod +x raw2jpeg.sh |
|
Last Updated ( Wednesday, 01 December 2010 )
|
Discuss this item on the forums. (1 posts)
|
|
getElementById fails on IE |
|
While working on a simple test page, I wanted to use getElementById to get an Image object from JavaScript. I quickly wrote up the code and tried it. Firefox was fine but it failed on my IE7 with "Microsoft JScript runtime error: Object doesn't support this property or method". It took some digging to see what the problem was. First thing I checked was that I used both element Name and Id and that they were the same. I *always* do that given that IE will use whichever one matches the desired string. After reading a few blog posts about common problems but with no good ideas I went back to my code and reviewed it carefully. It turns out that I used the same name for my element and my local JavaScript variable. That by itself isn't a problem but what made it an issue for me was that I failed to initialize my variable with the "var" keyword. See the code below for the example: <html> <head> <script type="text/javascript"> function getMyImg() { var myFirstImg = document.getElementById("myFirstImg"); mySecondImg = document.getElementById("mySecondImg"); <---This one will fail on IE7(probably IE5, IE6, IE8, IE9, IE...) if (myFirstImg.src == mySecondImg.src) { alert('src=' + mySecondImg.src); } } </script> </head> <body> <a href="#" onclick="getMyImg(); return false;">Do Something</a> <img id="myFirstImg" src="sample.png" /> <img id="mySecondImg" src="sample.png" /> </body> </html>
|
|
Last Updated ( Friday, 13 August 2010 )
|
Discuss this item on the forums. (0 posts)
|
|
|
<< Start < Prev 1 2 3 4 5 Next > End >>
|
| Results 1 - 4 of 17 |