Skip to content

Instantly share code, notes, and snippets.

View jed's full-sized avatar

Jed Schmidt jed

View GitHub Profile
@jed
jed / LICENSE.txt
Created May 9, 2011 16:17 — forked from 140bytes/LICENSE.txt
communicate with jsonp
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@jed
jed / koichi.coffee
Created May 5, 2011 17:11
an effort to replace koichi's outdated XML sig
class Component
constructor: ( @name ) ->
@fullname = "Koichi Kobayashi"
@email = "#{name}@___________.jp"
@blog = "http://d.hatena.ne.jp/#{name}"
@twitter = "http://twitter.com/#{name}"
new Component "koichik"
@jed
jed / bookmarklet.js
Created April 28, 2011 08:57
dom tree caching performance: array v. linked list. see also: http://jsperf.com/dom-trees/
javascript:with(document)(body.appendChild(createElement('script')).src='https://gist.github.com/raw/946036/8b51f04a6f9dbe15f5c375ac872a9ae56d4b8732/domTrees.js')._
@jed
jed / tweetToHTML.js
Created April 21, 2011 10:57
turning a tweet into html
function htmlify( tweet ) {
return tweet.replace(
/[@]+([A-Za-z0-9-_]+)|[#]+([A-Za-z0-9-_]+)|(\b(?:https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig,
function( match, user, tag, url ) {
return 0,
user ? "@" + user.link( "http://twitter.com/" + user ) :
tag ? "#" + tag.link( "http://search.twitter.com/search?q=%23" + tag ) :
url ? url.split( "//" )[ 1 ].link( url ) : ""
})
}
> Object.keys(global)
[ 'global',
'process',
'GLOBAL',
'root',
'Buffer',
'setTimeout',
'setInterval',
'clearTimeout',
'clearInterval',
@jed
jed / output.txt
Created April 18, 2011 03:43
"TypeError: Cannot convert object to primitive value"
$ node test.js
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot convert object to primitive value
at String.STRING_ADD_LEFT (native)
at isRegExp (util.js:287:14)
at format (util.js:184:11)
at util.js:216:19
<!-- in response to http://twitter.com/cramforce/status/57406808142266369 -->
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
function getFollowers( name, cb ) {
var obj = {}
jQuery.getJSON(
"https://api.twitter.com/1/followers/ids.json?screen_name=" + name + "&callback=?", cb
@jed
jed / README.md
Created April 11, 2011 04:20
turns a DOM into (fab) markup language

this is a (fab) experiment i've been toying with. it's a bookmarklet that serializes the DOM on the current page to (fab) code. the idea is to eventually be able to slurp out an existing page into static code, and then slowly start to introduce dynamic behavior using (fab).

to try it, create a bookmarklet with this source:

javascript:with(document)(body.appendChild(createElement('script')).src='https://gist.github.com/raw/913050/5e6c66b14256c12d4842945768e9351b1b798a27/index.js?'+Date.now())._

use with care, because it'll overwrite the current page contents. i think it'd be nice to use github's oauth support to save it in a gist.

@jed
jed / getVars.js
Created April 9, 2011 09:41
a function that takes code and returns a list of variable names needing declaration
var getVars = function( dummy, err, re ) {
try { eval( dummy ) } catch( e ) { err += e }
re = new RegExp( "^" + err.replace( dummy, "(\\w+)" ) + "$" )
return function( code ) {
var args = []
, name
while ( 1 ) {
@jed
jed / README.md
Created April 4, 2011 14:02
a small module for autorequiring. warning: MAGIC!

autorequire.js

Copyright (c) 2011 Jed Schmidt

a small module for auto-importing modules in node.js.

usage

require( "./autorequire" )
require.auto( <module-name> )