Skip to content

Instantly share code, notes, and snippets.

View jhawthorn's full-sized avatar
⌨️

John Hawthorn jhawthorn

⌨️
View GitHub Profile
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'pp'
require "active_record"
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.colorize_logging = true
UPDATE: Seems to be fixed.
With the commit at http://github.com/carz2/cm-kernel/commit/e337c700209ae09ce80e60d7e3c5306b57a9f709
My phone now charges properly while plugged in.
The value in /sys/class/power_supply/battery/charging_enabled has changed to 1.
=============================================================================
Problems with the kernel for HTC magics with the 6.35 radio
Kernel used is a compile of http://github.com/carz2/cm-kernel
@jhawthorn
jhawthorn / alarm.rb
Created March 14, 2011 23:59
alarm which rings until your google reader entries are all read
require 'rubygems'
require 'net/http'
require 'nokogiri'
require 'time'
Auth = 'YOUR AUTH KEY'
def unread_items
headers = {'Authorization' => "GoogleLogin auth=#{Auth}" }
@jhawthorn
jhawthorn / mcirc.rb
Created June 10, 2011 20:34
Minecraft to IRC bridge
#!/usr/bin/env ruby
require 'socket'
require 'uri'
class MinecraftIrcBot
def initialize(options)
uri = URI.parse("irc://#{options[:server]}")
@channel = options[:channel]
@socket = TCPSocket.open(uri.host, uri.port || 6667)
@jhawthorn
jhawthorn / paperclip_interpolator.rb
Created March 2, 2012 23:05
paperclip interpolator
class PaperclipInterpolator
def initialize pattern
@pattern = pattern
@methods = []
@template = Paperclip::Interpolations::all.reverse.inject( pattern.dup ) do |result, tag|
result.gsub(/:#{tag}/) do |match|
@methods << tag.to_sym
"%{#{tag}}"
end
end
@jhawthorn
jhawthorn / README.md
Created September 18, 2012 04:44
Huawai E220 - EMobile japan

pacman -S wvdial usb_modeswitch

reboot

@jhawthorn
jhawthorn / gotoh.c
Last active September 13, 2019 04:18
/*
* gotoh.c
* Compute a sequence alignment with an affine gap cost
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <float.h>
@jhawthorn
jhawthorn / hadfield.rb
Last active December 14, 2015 10:29
Set the latest tweet from @Cmdr_Hadfield as desktop background
require 'json'
require 'open-uri'
TIMELINE_URL = 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=Cmdr_Hadfield&include_entities=true&trim_user=true&exclude_replies=true'
class Tweet < Struct.new(:tweet)
def media
tweet['entities']['media'][0]
end
def image_url
@jhawthorn
jhawthorn / humans.c
Last active December 14, 2015 11:08
Hey sexy mama, Wanna kill all humans?
/* humans.c
* $ gcc -o humans humans.c
* $ ./humans &
* $ killall humans
*/
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
class Spreadsheet
def initialize
@hash = Hash.new(0)
end
class Subset < Struct.new(:spreadsheet, :row, :col)
def [] k
return k.map{|x| self[x]} if k.respond_to? :map
spreadsheet[cell k]
end
def []= k, v