Skip to content

Instantly share code, notes, and snippets.

Dustin Diaz ded

Block or report user

Report or block ded

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 swift-hepers.swift
// 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
@ded
ded / app.js
Created May 15, 2013
get dependency tree
View app.js
function init(config) {
var util = require('app/util')
, render = require('client/lib/render')
, router = require('client/lib/router')
, controllers = config.controllers
controllers.forEach(function (c) {
require(c)
})
}
@ded
ded / ender.delay.js
Created Nov 19, 2011
ender delay()
View ender.delay.js
!function ($) {
$.ender({
delay: function (n) {
var mock = {}
, chain = []
, key
, $el = $(this)
for (key in $el) {
if (isFinite(key)) continue
!function (key) {
@ded
ded / app.js
Created Oct 21, 2011
Rails-like routes for Express
View app.js
var express = require('express')
, app = express.createServer()
require('./config/routes').initialize(app)
View module.js
!function (name, definition) {
if (typeof define == 'function' && define.amd) define(name, definition)
else if (typeof module != 'undefined') module.exports = definition()
else this[name] = definition()
}('thing', function () {
// codes
return module
})
@ded
ded / cmd
Created Sep 21, 2011
ender | backbone
View cmd
ender build backbone
@ded
ded / parallel.js
Created Jul 21, 2011
call multiple async methods in parallel and receive the result in a callback
View parallel.js
function parallel() {
var args = Array.apply(null, arguments)
, callback = args.pop()
, returns = []
, len = 0
args.forEach(function (el, i) {
el(function () {
var a = Array.apply(null, arguments)
, e = a.shift()
if (e) return callback(e)
@ded
ded / virtual-hosts-connect.js
Created Jul 13, 2011
run multiple hosts (domains) on a single node process
View virtual-hosts-connect.js
var connect = require('connect')
, app = require('./app')
, app2 = require('./app2')
connect(
connect.vhost('dustindiaz.com', app)
, connect.vhost('foobar.dustindiaz.com', app2)
).listen(3000)
View preload.js
test_script_elem = document.createElement("script"),
explicit_preloading = typeof test_script_elem.preload == "boolean",
real_preloading = explicit_preloading || (test_script_elem.readyState && test_script_elem.readyState == "uninitialized"),
script = document.createElement('script')
if (real_preloading) {
registry_item.elem = script;
if (explicit_preloading) {
@ded
ded / app.html
Created Jun 29, 2011
ender CLI example
View app.html
<script src="ender.min.js"></script>
<script>
$.require('/js/core.min.js', 'core')
$.ready('core', function () {
$(document).ready(function () {
$('<p>hello world</p>').appendTo('body')
.bind('click', function (e) {
$.require('/js/ajax.min.js', function () {
You can’t perform that action at this time.