Skip to content

Instantly share code, notes, and snippets.

Working from home

Daniel Huckstep darkhelmet

Working from home
Block or report user

Report or block darkhelmet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View surl.php
Plugin Name: Tweet with surl
Plugin URI:
Description: Use surl with Twitter Tools
Version: 1.0
Author: Daniel Huckstep
Author URI:
function get_content($url)
View feedzirra-example.rb
feed.entries.each do |e|
"Looking at the entry #{e.title.gsub("n",' ')}".printn
link = (Nokogiri(e.summary)/"img").to_html
next if link.empty?
link = link[/"(.*)"/].gsub(/["]/,'')
filename = link.split('/').last
disk_file = File.expand_path(File.join(ROOT,filename))
unless File.exists?(disk_file)
"Downloading new image #{filename}...".print
View pascal_to_human.cs
public static string ToHumanFromPascal(this string s)
if (2 > s.Length)
return s;
var sb = new StringBuilder();
var ca = s.ToCharArray();
View einstein-by-hand.js
var theElement = "einstein-sb";
var req = false;
function loadXMLDoc(url, method, async) {
if (window.XMLHttpRequest)
View broken_regex.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
# this fails matching /2009/04/30/borland-c++-builder-5-how-i-hate-thee
get %r|^/\d{4}/\d{2}/\d{2}/[\w\d\-+]+$| do |match|
p match
View cache.rb
class Cache < ActiveRecord::Base
serialize :value
def self.get(key, max_age = 1.hour)
item = Cache.first(:conditions => { :key => key })
if block_given?
if item.nil? || item.updated_at < max_age.ago
value = yield
View gist:193606
$(document).ready(function() {
$.doAfter(2500, function() {
$('#my-elem').show("bounce", { times: 6 }, 300);
View gist:193889
Content-Type: multipart/form-data; boundary=----------------------------f2404c5f8da2
Content-Disposition: form-data; name="name"
Content-Disposition: form-data; name="file"; filename="astring"
Content-Type: application/octet-stream
View download.rb
main_links.each do |link|
dir = link.split('.').first # i get 'name' or 'name-2' to download into
page = Hpricot(open("#{domain}/#{link}"))
links ='a').select do |l|
l.attributes['href'] =~ /javascript:OpenLink\((.*)\)/
!($1 =~ /^\'\w+\.\w+\'$/) do |l|
l.attributes['href'].to_s =~ /javascript:OpenLink\(\'(.*)\'\)/
View unescape.js
String.prototype.unescape = function() {
var node = document.createElement('div');
node.innerHTML = this;
if('undefined' == typeof(node.innerText)) {
return node.textContent; // FF
return node.innerText; // IE
You can’t perform that action at this time.