Skip to content

Instantly share code, notes, and snippets.

View ded's full-sized avatar
🏃
always working, sometimes running

Dustin Diaz ded

🏃
always working, sometimes running
View GitHub Profile
document.domain = 'dustindiaz.com';
function fn () {
document.write = "";
window.top.location = window.self.location;
setTimeout(function() {
document.body.innerHTML = '';
}, 0);
window.self.onload = function(evt) {
document.body.innerHTML = '';
};
@ded
ded / digit-to-romans.js
Created November 25, 2010 20:22
You never know when you might need to convert digits to roman numerals
var table = ['i', 'v', 'x', 'l', 'c', 'd', 'm'];
var map = {
4: "01",
5: "1",
6: "10",
7: "100",
8: "1000",
9: "02"
};
@ded
ded / Throttler.js
Created October 28, 2010 18:16
A utility that throttles input to a timer
/**
* requires twttr.klass
*/
twttr.klass('twttr.Throttler', function(interval, callback) {
this.interval = interval;
this.callback = callback;
this._items = [];
})
@ded
ded / widget-filters.js
Created October 18, 2010 23:24
using filters in twitter widget
new TWTR.Widget({
version: 2,
type: 'profile',
rpp: 20,
interval: 6000,
width: 'auto',
height: 300,
theme: {
shell: {
@ded
ded / twttr.klass.js
Created October 15, 2010 18:13
A simple Class system with a familiar interface
(function() {
window.twttr = window.twttr || {};
aug(twttr, {
klass: function(ns, init) {
var c = function() {
init.apply(this, arguments);
};
@ded
ded / Location-parts.js
Created October 15, 2010 00:41
Mimics the window.location parts when given a URL
twttr.klass('twttr.util.Location', function(url) {
if (url.match(/^\/\//)) {
url = 'http:' + url;
} else if (!url.match(/^[a-z]+:\/\//)) {
url = 'http://' + url;
}
var m = url.match(/^([a-z]+:)\/\/([\w\-\.]+)(\:\d+)?(.+)?/);
this.href = url;
this.protocol = m[1];
this.hostname = m[2];
/*----------------------- OMG TWITTER -------------------------------------*/
twttr.mediaType('twttr.media.types.Twitter')
.matcher(/\b(?:(?:https?\:\/\/)?(?:www\.)?)?twitter\.com\/(?:(?:#|#!)\/)?(?:\w{1,20})\/status\/(\S+)/gi)
.icon("generic")
.favicon("http://twitter.com/phoenix/favicon.ico")
.url('http://twitter.com')
@ded
ded / swift-hepers.swift
Last active August 29, 2015 14:23
Swiftys
// custom RegEx Class
// let string: String = "foo bar baz"
// let regex: Regex = "foo"
// regex.match(string) // true
// "foo".match(string) // true
// "foo bar baz" =~ "foo" // true