Is all the boilerplate you need to run rake tasks as a script, from anywhere in the filesystem.
Monday, September 19, 2011
Running Rake as a script
Rake seemed nice, but I needed some of it for a server side trick. Not difficult, but if you're new to it, it's tough to find just what you need.
Tuesday, March 29, 2011
Controlling android via http(s) over usb
I've been playing with couchdb, and was playing with the paw web server for android (http://paw-android.fun2code.de/), and discovered something interesting.
* If you turn on usb teathering, then connect your phone to a linux box, it'll automatically add usb0 as a connection.
* If you grab the default route for usb0, you'll have the ip of your android phone.
* If you run paw, you'll be able to do things like send sms, control your phone, etc.
* If you run, (and tweak the config), you'll be able to connect to the couchdb on your phone
* You don't have to access these services via a web browser, (yay! SMS from emacs!)
* paw server also has stuff like "play music from phone", and "use phone as webcam", etc. etc. etc.
I suppose I knew all this was possible, but I didn't think it would be "done in 5 minutes" possible...
* If you turn on usb teathering, then connect your phone to a linux box, it'll automatically add usb0 as a connection.
* If you grab the default route for usb0, you'll have the ip of your android phone.
* If you run paw, you'll be able to do things like send sms, control your phone, etc.
* If you run, (and tweak the config), you'll be able to connect to the couchdb on your phone
* You don't have to access these services via a web browser, (yay! SMS from emacs!)
* paw server also has stuff like "play music from phone", and "use phone as webcam", etc. etc. etc.
I suppose I knew all this was possible, but I didn't think it would be "done in 5 minutes" possible...
Monday, March 14, 2011
Python lockfiles
The python-daemon library has a nice implementation of pidfiles, much better than the standard lib lockfile. i.e.
import lockfile.pidlockfile as pidlock
lf = pidlock.PIDLockFile("/tmp/mqtask.pid")
# module methods
pidlock.read_pid_from_pidfile
pidlock.remove_existing_pidfile
pidlock.write_pid_to_pidfile
import lockfile.pidlockfile as pidlock
lf = pidlock.PIDLockFile("/tmp/mqtask.pid")
# module methods
pidlock.read_pid_from_pidfile
pidlock.remove_existing_pidfile
pidlock.write_pid_to_pidfile
Monday, June 21, 2010
Airbnb sounds cool, but I really want Walk-in-closet-to-go
I don't like packing.
When I look around my house, I see the progress I've made towards living a less-stuff lifestyle, such as advocated by Paul Graham, among many others, (see Stuff.) Still, I don't think I'll reach the point where I can comfortably live out of a suitcase or a backpack without significantly reducing the quality of my life.
So what about a service more like AirBnB + PODS + A Closet organizer something like this + Robotic movers similar to these = Easy, comfortable, continuous travel.
Just playing with numbers on the back of an envelope, I think this would be both possible and cheap, in the near future.
Hmmmm....
When I look around my house, I see the progress I've made towards living a less-stuff lifestyle, such as advocated by Paul Graham, among many others, (see Stuff.) Still, I don't think I'll reach the point where I can comfortably live out of a suitcase or a backpack without significantly reducing the quality of my life.
So what about a service more like AirBnB + PODS + A Closet organizer something like this + Robotic movers similar to these = Easy, comfortable, continuous travel.
Just playing with numbers on the back of an envelope, I think this would be both possible and cheap, in the near future.
Hmmmm....
Monday, June 7, 2010
Using Apache Camel from Clojure
I've been looking at Apache Camel for a project at work, and had a bit of trouble getting it working from Clojure, so I wrote this up in case anyone has the same issues.
The first example in Camel in Action watches a directory for new files, and copies them to an output directory. Here are the steps to get that running in Clojure, using leiningen.
Part of what screwed me up was the fact that you need to include spring in the project in order to get camel to work properly.
You can also use a macro to make the code even cleaner, like this:
Which I think compares nicely to the original Java:
I'm sure there are more improvements possible, but this got me started.
The first example in Camel in Action watches a directory for new files, and copies them to an output directory. Here are the steps to get that running in Clojure, using leiningen.
- Create your input and output directories
- Create a new leiningen project
- Add the following to the project.clj
- run lein deps
- Add the following to your src/org/whitlark/fc.clj (or whatever your last name is ;-)
Part of what screwed me up was the fact that you need to include spring in the project in order to get camel to work properly.
You can also use a macro to make the code even cleaner, like this:
Which I think compares nicely to the original Java:
I'm sure there are more improvements possible, but this got me started.
Friday, April 23, 2010
Extending the range of a PS3 controller.
Just plug a short usb cable (I use 12"), and leave the other end unplugged. The cable seems to act like an antenna, giving you a better connection. I've not done any tests to see exactly how much you can get, but I get at least another 10'.
I'm thinking about opening up the controller and soldering an antenna to the usb enclosure. If I do that, I'll post instructions/video.
I'm thinking about opening up the controller and soldering an antenna to the usb enclosure. If I do that, I'll post instructions/video.
Monday, June 22, 2009
Quick post on working with large changes across your codebase
Stuff I wrote up for work. Ignore the p4 part, assuming you use a real version control system, *cough* git.
Strategies for making changes that affect a large number of files
emacs:
- recursive editing (C-r, C-M-c)
- find-grep-dired
- ibuffer (Used to save large number of buffers at once)
- dired-do-query-replace-regexp (find-replace across marked files in dired buffer)
shell:
- grep -rIl 'pattern' * > files_to_op_on (that's a capital i and a lowercase L)
- grep option -r: recurse
- grep option -I: (capital i) exclude binary files
- grep option -l: (lowercase L) Show only filenames with matching content, no other output.
- grep option -h: don't include filename in the match line.
- cat files_to_op_on | xargs sed -i backup_extension 's/old/new/g' #Note that bsd sed required a backup extension with the -i argument.
- cat files_to_op_on | xargs p4 edit
Watch out for symlinks! If you get them in your changelist, p4 won't accept submit, in which case you'll need to delete them via p4 change.
p4 submit > /dev/nullworks well to just get the errors.
The general pattern of:
grep -rI 'something' * | sort -ucan show you the variations you'll need to fix. If you want to get rid of leading whitespace in your results, try piping through:
sed -E -e 's/^[[:space:]]+//'
Subscribe to:
Posts (Atom)