Skip to content

Instantly share code, notes, and snippets.

@sessa
sessa / app.js
Created March 3, 2014 22:52 — forked from mdellanoce/app.js
var express = require('express'),
requirejs = require('requirejs'),
app = module.exports = express.createServer();
app.configure('development', function(){
// Use development version of static files
app.use(express.static(__dirname + '/public'));
});
app.configure('production', function(){
// preserve Twitter's style of JSON string encoding...
// escape higher value unicode (lowercase hex)
// escape < and > (uppercase hex)
// escape / in strings (\/)
// hugs! https://gist.github.com/1306986
// http://stackoverflow.com/questions/4901133/json-and-escaping-characters
function escapedStringify(s, emit_unicode) {
var json = JSON.stringify(s);
return emit_unicode ? json : json.replace(/\//g,
function(c) {
@sessa
sessa / app.coffee
Created February 5, 2014 14:50 — forked from aseemk/app.coffee
bunyan = require 'bunyan'
restify = require 'restify'
requireDir = require 'require-dir'
middleware = requireDir './middleware'
routes = requireDir './routes'
settings = require './settings'
app = restify.createServer
name: 'Foo Bar API'
@sessa
sessa / ios-test.css
Created December 6, 2012 22:09 — forked from tonywok/ios-test.css
iOS Media Queries
// iOS Media Queries
// Goal: capture styles for iPhone, iPhone 3G, iPhone 3GS, iPhone 4, iPhone 4S, iPad, and iPad 2
//
// Author: Tony Schneider (@tonywok)
// Please tell me where I fail. :)
// iPhone v(4,4S) portrait
// test: black text (overwritten by v* portrait) with blue background
@media all and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait) {
a {
@sessa
sessa / emailer.rb
Created October 6, 2012 20:51 — forked from mweppler/emailer.rb
A ruby emailer
# http://ruby-doc.org/stdlib-1.9.3/libdoc/net/smtp/rdoc/Net/SMTP.html
require 'digest/md5'
require 'mime/types'
require 'net/smtp'
require 'optparse'
require 'ostruct'
require 'yaml'
class Emailer
@sessa
sessa / .gitignore
Created August 16, 2012 18:32 — forked from redoPop/.gitignore
Template .gitignore file for WordPress projects
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments +below for more info on how to add exceptions for your
@sessa
sessa / interval.js
Created June 21, 2012 00:15 — forked from gengkev/interval.js
Accurate Javascript setInterval replacement
function Interval(func,duration){
if(typeof func !== "function") throw new TypeError("Expected function");
else if(typeof duration !== "number") throw new TypeError("Expected number");
this.func = func;
this.duration = duration;
this.baseline = +new Date();
(function(_this){
_this.timer = setTimeout(function(){
@sessa
sessa / interval.js
Created June 21, 2012 00:07 — forked from manast/interval.js
Accurate Javascript setInterval replacement
interval: function (duration, callback){
var baseline = undefined;
return {
run: function() {
if( baseline === undefined ) {
baseline = new Date().getTime();
}
callback();
var end = new Date().getTime();
baseline += duration;
@sessa
sessa / jquery.selectbox-1.2.js
Created May 31, 2012 02:14 — forked from itsadok/jquery.selectbox-1.2.js
jQuery selectbox plugin
/*
* jQuery selectbox plugin
*
* Copyright (c) 2007 Sadri Sahraoui (brainfault.com)
* Licensed under the GPL license and MIT:
* http://www.opensource.org/licenses/GPL-license.php
* http://www.opensource.org/licenses/mit-license.php
*
* The code is inspired from Autocomplete plugin (http://www.dyve.net/jquery/?autocomplete)
*
@sessa
sessa / snippet.js
Created May 29, 2012 03:31 — forked from christopherdebeer/snippet.js
Node.js Express - Mobile detection
app.get('/', function(req, res){
var ua = req.header('user-agent');
if(/mobile/i.test(ua)) {
res.render('mobile.html');
} else {
res.render('desktop.html');
}
});