Skip to content

Instantly share code, notes, and snippets.

View darkhelmet's full-sized avatar
🏠
Working from home

Daniel Huckstep darkhelmet

🏠
Working from home
View GitHub Profile
<?php
/*
Plugin Name: Tweet with surl
Plugin URI: http://s.darkhax.com
Description: Use surl with Twitter Tools
Version: 1.0
Author: Daniel Huckstep
Author URI: http://www.darkhax.com
*/
function get_content($url)
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
Net.download_and_save(link,disk_file)
public static string ToHumanFromPascal(this string s)
{
if (2 > s.Length)
{
return s;
}
var sb = new StringBuilder();
var ca = s.ToCharArray();
sb.Append(ca[0]);
var theElement = "einstein-sb";
var req = false;
getEinsteinInfo();
function loadXMLDoc(url, method, async) {
try
{
if (window.XMLHttpRequest)
{
#!/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
end
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
begin
value = yield
Cache.put(key,value)
$(document).ready(function() {
$.doAfter(2500, function() {
$('#my-elem').show("bounce", { times: 6 }, 300);
});
});
Content-Type: multipart/form-data; boundary=----------------------------f2404c5f8da2
------------------------------f2404c5f8da2
Content-Disposition: form-data; name="name"
something
------------------------------f2404c5f8da2
Content-Disposition: form-data; name="file"; filename="astring"
Content-Type: application/octet-stream
main_links.each do |link|
dir = link.split('.').first # i get 'name' or 'name-2' to download into
begin
page = Hpricot(open("#{domain}/#{link}"))
links = page.search('a').select do |l|
l.attributes['href'] =~ /javascript:OpenLink\((.*)\)/
!($1 =~ /^\'\w+\.\w+\'$/)
end.map do |l|
l.attributes['href'].to_s =~ /javascript:OpenLink\(\'(.*)\'\)/
decode_url($1)
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
}