Skip to content

Instantly share code, notes, and snippets.

@powdahound
powdahound / gist:958148
Created May 5, 2011 22:54
HipChat API message with HTML
<?php
// HipChat PHP library: https://github.com/hipchat/hipchat-php
include 'HipChat.php';
$token = "<your token>";
$room = "Development";
$message = 'Some <b>html</b>, &lt;entities&gt;, and a <a href="https://www.hipchat.com">link</a>.<br />We can even use line breaks!';
$hc = new HipChat($token);
@powdahound
powdahound / hipchat_bot.js
Created April 25, 2011 18:35
Basic XMPP bot example for HipChat using node.js
// Basic XMPP bot example for HipChat using node.js
// To use:
// 1. Set config variables
// 2. Run `node hipchat_bot.js`
// 3. Send a message like "!weather 94085" in the room with the bot
var request = require('request'); // github.com/mikeal/request
var sys = require('sys');
var util = require('util');
@powdahound
powdahound / gist:933104
Created April 20, 2011 22:15
Working runit setup for couchdb-lucene that will properly restart on OOM
We couldn’t find that file to show.
# On Ubuntu 10.04.1 LTS this is added "libmozjs-dev" after upgrading form 0.9.8 to 0.9.12
dev_pkgs << value_for_platform(
"debian" => { "default" => "libmozjs-dev" },
"ubuntu" => {
"9.04" => "libmozjs-dev",
"9.10" => "libmozjs-dev",
"default" => "xulrunner-dev"
}
)
#!/usr/bin/python
import os
def daemonize():
# See http://www.faqs.org/faqs/unix-faq/programmer/faq/ - Section 1.7
print('--- %s: daemonizing' % os.getpid())
if os.fork(): # launch child and...
print('--- %s: kill parent 1' % os.getpid())
os._exit(0) # kill off parent
@powdahound
powdahound / gist:575380
Created September 11, 2010 17:36
GitHub tarball extract & cd
GitHub tarball downloads contain a folder inside named: <user>-<project>-<hash>
$ tag='v1.3.12'
$ curl -sL http://github.com/antirez/redis/tarball/$tag -o redis-$tag.tar.gz
$ dir=$(tar zxvf redis-$tag.tar.gz | tail -1 | cut -d "/" -f1)
$ cd $dir
$ make
Is there a cleaner way to cd to the directory inside the tarball?
2010-09-03_14:34:24.70801 Merb root at: /usr/lib/ruby/gems/1.8/gems/chef-server-api-0.9.8
2010-09-03_14:34:24.70808 ~ No Gemfile found! If you're generating new app with merb-gen this is fine, otherwise run: bundle init to create Gemfile
2010-09-03_14:34:24.70822 Loading init file from ./config/init.rb2010-09-03_14:34:25.06675 WARN: HTTP Request Returned 500 Internal Server Error: error
2010-09-03_14:34:25.06701 /usr/lib/ruby/1.8/net/http.rb:2097:in `error!': 500 "Internal Server Error" (Net::HTTPFatalError)
2010-09-03_14:34:25.06713 from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/lib/chef/rest.rb:229:in `api_request'
...
deploy_branch "/tmp/txredis" do
repository "git://github.com/deldotdr/txRedis.git"
branch "master"
restart_command "python setup.py install"
purge_before_symlink Array.new
create_dirs_before_symlink Array.new
symlinks Hash.new
symlink_before_migrate Hash.new
end
@powdahound
powdahound / main.js
Created August 23, 2010 04:02
node.js model setup?
var task = require('./task');
var t1 = new(task.Task)("Blah");
var t2 = new(task.Task)("Foo");
sys.puts(t1.getBody());
sys.puts(t2.getBody());
var tasks = task.getTasks();
sys.puts(sys.inspect(tasks));
squaw:/tmp curl http://npmjs.org/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
122 244 122 244 0 0 1088 0 --:--:-- --:--:-- --:--:-- 2904
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 555k 100 555k 0 0 62125 0 0:00:09 0:00:09 --:--:-- 74607
node cli.js cache clean
npm it worked if it ends with ok
npm cli [ 'cache', 'clean' ]