Skip to content

Instantly share code, notes, and snippets.

View Voker57's full-sized avatar

Voker57 Voker57

View GitHub Profile
=begin
Tokyo Cabinet vs. SQLite indexed string selection & inserting test
Install gems "tokyocabinet" and "sqlite-ruby"
% ruby test.rb
Creating SQlite db.. user system total real
Generating test data... 100.700000 8.500000 109.200000 (110.876452)
Generating random selection set... 0.160000 0.050000 0.210000 ( 0.202189)
require 'uri/http'
require 'net/http'
if ARGV.size < 2
puts "Usage: lyrics.rb <Artist> <Title>"
exit 1
end
artist = URI.escape(ARGV[0])
title = URI.escape(ARGV[1])
#!/usr/bin/env ruby
# usage: ./shitcounter.rb firefox log.txt
browser = ARGV[0]
logfile = File.open(ARGV[1], "w")
def ps_aux(grep = nil)
unf = `ps aux`.split("\n")[1..-1].map do |v| v.split(/\s+/) end
if grep
unf.select do |v|
#!/bin/sh
TEMP=`mktemp`
rm $TEMP
zip -u $TEMP $2
cat $1 $TEMP > $3
rm $TEMP
@Voker57
Voker57 / defilefb2
Created June 25, 2010 17:30
Converts fb2 files into somewhat plain text
#!/bin/sh
TEMP=`mktemp -d`
unzip -d $TEMP $1
for fb2 in $TEMP/*.fb2; do
html2text -ascii $fb2 | enconv -L ru -x CP1251 > $fb2.txt
rm $fb2
done
rm $1
zip -j $1 $TEMP/*
@Voker57
Voker57 / arch.rb
Created July 11, 2010 13:48
Optimally fits files into zip archives. I think.
# usage: ruby arch.rb <size> <files...>
size = ARGV.shift.to_i
$sizes_map = []
ARGV.each do |f|
$sizes_map << [File.size(f), f]
end
#!/bin/sh
echo "Cleaning up..."
rm 00-index.tar.gz
mkdir -p package
echo "Downloading index..."
wget http://hackage.haskell.org/packages/archive/00-index.tar.gz
for splitpk in `tar tf 00-index.tar.gz | cut -d/ -f 2,3`; do
pk=`echo $splitpk | sed 's|/|-|'`
name=$pk.tar.gz
@Voker57
Voker57 / ac.sh
Created September 25, 2010 20:20
AstralCat, netcat using Astral for locating adversary. Inspired by gnunet papers on discovering nodes.
#!/bin/bash
# AstralCat
# Transmits data over IPv4 net using Astral routing
#
if [ -z $1 ] ; then
echo "Usage:"
echo "ac scream < file # transmit data"
echo "ac listen > file # receive data"
-- Bitcoin (฿) daemon monitor
-- %bitcoin_speed - current speed in khash/s
-- %bitcoin_balance - current balance
-- by Voker57 <voker57@gmail.com>
-- Public domain
local defaults={
update_interval=30 * 1000
#!/usr/bin/env python
# Readable Python syntax implementation in pure Python
# See http://tinyurl.com/3xhqgs for syntax description
# Usage: ./rpython.py hello_world.py
# This program greatly improves python syntax, blah blah blah
from subprocess import call
import sys