msgbartop
Tips, notes, HOWTOs
msgbarbottom

06 Dec 08 Increase Loadaverage

Increase the load average on a machine for testing.

while true; do w & w & w & w; done

Tags: ,

06 Dec 08 Remove Whitespace From The End Of Lines

Nice sed tip to remove extra whitespace at the end of lines in a file.

sed -e 's/ *$//' <file>

Tags: ,

05 Dec 08 Pause Torrent Downloads When Screensaver Is Inactive

If you use Transmission this little python script will start all of your downloads when your screensaver kicks on and pause them when it turns off, i.e. you are at your terminal.

#!/usr/bin/env python
import dbus, urllib
from dbus.mainloop.glib import DBusGMainLoop

START_TORRENTS = "http://localhost:9091/transmission/rpc?method=torrent-start"
STOP_TORRENTS = "http://localhost:9091/transmission/rpc?method=torrent-stop"

DBusGMainLoop(set_as_default=True)
sess=dbus.SessionBus()
def sig(screensaverActive):
  if screensaverActive:
    data = urllib.urlopen(START_TORRENTS).read()
  else:
    data = urllib.urlopen(STOP_TORRENTS).read()

sess.add_signal_receiver(sig, 'ActiveChanged','org.gnome.ScreenSaver')
import gobject
loop = gobject.MainLoop()
loop.run()

via I can’t find it at the moment but I will update once I get the link.  :(

UPDATE:

I found my source here.  The comments also include a patch for throttling the app rather than outright pausing everything.

SECURITY: I should point out, as mentioned in this comment, the RPC for Transmission will allow a nefarious person to control your application with a web page that includes elements like:

<img src="http://localhost:9091/transmission/rpc?method=torrent-stop">

It is assumed that most (all?) other RPC calls for the web interface of Transmission could be called the same way.  This is a fairly large security hole and I would suggest using a password on the Transmission web interface if you enable it.  Though if you do that would render this tip pretty much useless.

Tags: , , , ,

05 Dec 08 Automatically Connect When A Host Comes Up

Ping a host until it answers and then connect.  I actually have this in a script that will use the first argument as the host.

while ! ping -W 1 -c 1 <hostname or IP> 2>&1 >/dev/null; do true; done && sleep 15; ssh <user>@<hostname or IP>

via The Linux Blog

Tags: ,

SEO Powered by Platinum SEO from Techblissonline