Skip to content

Instantly share code, notes, and snippets.

+—— ——+
| |
| |
+—— ——+
+—— ——+ +————————————————+ +—— ——+ +—— ——+
| | | |
import Foundation
let ScanLines = RegExScanFn("\n|\r|\r\n")
let ScanWords = RegExScanFn("\\s")
func RegExScanFn(regex : String) -> ((String) -> (String, String?)) {
return { (s : String) -> (String, String?) in
let ns = s as NSString
let location = ns.rangeOfString(regex, options: .RegularExpressionSearch).location
if location != NSNotFound {
@burnto
burnto / gist:8d2f43d4de5f8e09de16
Last active August 29, 2015 14:14
How to create a This. bookmarklet on mobile Safari.

It's a couple extra steps, but really not too hard.

  1. Create a bookmark for "This." and save it.

  2. Go back to your bookmarks and tap "Edit".

  3. Select your "This." bookmark.

  4. Replace the URL with the following:

    javascript:%28function %28d%2Cs%2Cp%29 %7Bd %3D document%3Bif %28typeof this_counter_8532 %21%3D%3D %27undefined%27%29 %7Bp %3D d.getElementById%28%27this-modal-%27 %2B this_counter_8532%29%3Bif %28p%29 %7Bp.parentNode.removeChild%28p%29%3Breturn%3B%7D%7Dthis_counter_8532%3DparseInt%28Math.random%28%29 %2A 100000%29 %2B 123456%3Bs %3D d.createElement%28%27script%27%29%3Bs.type %3D %27text%2Fjavascript%27%3Bs.setAttribute%28%27src%27%2C %27https%3A%2F%2Fthis.cm%2Fbookmarklet%2Fshim%2F%27 %2B this_counter_8532%29%3Bd.body.appendChild%28s%29%3B%7D%29%28%29%3B
    
def mail_to_obf(email_address, name = nil, html_options = {})
substr = ' *AT* '
ej = email_address.gsub(/@/, substr)
mt = mail_to(ej, name || ej, html_options)
javascript_tag("document.write('#{mt}'.replace('#{substr}', '@', 'g'))")
end
# Detect rss feed, parse it, and report number of posts per date.
require 'rubygems'
require 'hpricot'
require 'open-uri'
# First find the rss
url = ARGV[0] || "http://twitter.com/burnto"
doc = Hpricot(open(url))
# Detect rss feed, parse it, and report number of posts per date.
require 'rubygems'
require 'hpricot'
require 'open-uri'
# First find the rss
url = ARGV[0] || "http://twitter.com/burnto"
doc = Hpricot(open(url))
@burnto
burnto / all youtube comments in a category
Created December 8, 2009 08:10
grab retarded youtube comments for category or keyword
require 'rubygems'
require 'hpricot'
require 'open-uri'
n = ARGV[0]
n = n.gsub(/\s+/, "%2C%2D")
xml = open("http://gdata.youtube.com/feeds/api/videos?category=#{n}").read
doc = Hpricot::XML(xml)
Array.prototype.simple_moving_average = function(window_length) {
var averaged = new Array(this.length);
var chunk = [];
for (k = 0; k < this.length; k++) {
chunk.push(this[k]);
if (chunk.length > window_length) chunk.shift();
averaged[k] = chunk.sum() / chunk.length; // sum() is an exercise left to the reader
}
return averaged;
};
@burnto
burnto / happy.md
Created October 20, 2010 02:04 — forked from huned/happy.md

Some stuff that makes me happy:

  • good decisions
  • well written, persuasive prose
  • elegant solutions
  • evocative experiences
  • genuine, honest communication
  • afterglow
  • summertime
  • doodling