Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
from lxml import etree
doc = etree.parse("http://www.8bitpeoples.com/feed/feed.rss")
links = doc.xpath("//link/child::text()")
albums = [link[-6:] for link in links if 'discography' in link]
print "\n".join(albums)
#!/usr/bin/env ruby
require 'rubygems'
require 'open-uri'
require 'nokogiri'
class Array
alias :_old_index_op :[]
def [] a
if a.is_a?(Regexp) then
<?php
$link = mysql_connect('localhost', 'root');
function mysql_results($result) {
$foos = array();
while ($row = mysql_fetch_row($result)) {
$foo = $row[0];
array_push($foos, $foo);
}
#!/bin/sh
# Usage: gemcopy [user@]hostname
ruby << LOCAL_RB | sudo sh
require 'rubygems'
specs = Gem.source_index.search ""
local_spec_tuples = specs.map do |spec|
[spec.name, spec.version.to_s]
end
remote_spec_tuples = `
#!/usr/bin/env ruby
require 'rubygems'
dep = Gem::Dependency.new '', Gem::Requirement.default
specs = Gem.source_index.search dep
specs.each do |spec|
print "gem install #{spec.name} -v #{spec.version} --no-rdoc --no-ri\n"
end
#!/usr/bin/env perl -w
sub foo() {
$pw = `pwgen -ABn 4 1`;
($a, $b, $c, $d) = unpack('cccc', $pw);
$dom[0] = pack('cccc', $a, $b, $c, $d) .'.com';
$dom[1] = pack('cccc', $b, $a, $c, $d) .'.com';
$dom[2] = pack('cccc', $a, $c, $b, $d) .'.com';
$dom[3] = pack('cccc', $a, $b, $d, $c) .'.com';
#!/bin/sh
ec2din | grep $(host $1 | cut -d' ' -f4) | cut -f2
class Fixnum
def split(bits, count)
array = []
value = ord
mask = (1 << bits) - 1
count.times do
array << (value & mask)
value = value >> bits
end
array
int allocate(blocks *b) {
int i;
i = (b->index + 1) % b->size;
while (i != b->index) {
if (b->map[i] == 0) {
b->map[i] = 1;
b->index = i;
return i;
}
i = (i + 1) % b->size;
steer = 0;
gas = 0;
/* Input */
// Xbox 360 Controller
steer = steer - SDL_JoystickGetAxis(joystick, 0) / 32768.0;
gas = gas + ( SDL_JoystickGetAxis(joystick, 4) / 32768.0 + 1 ) / 2.0;
// Keyboard