Skip to content

Instantly share code, notes, and snippets.

View wavded's full-sized avatar
🐢
Turtles all the way

Marc Harter wavded

🐢
Turtles all the way
View GitHub Profile
/* Overwrite localStorage w/ cookie-based storage if browser does not support */
if(typeof localStorage === "undefined" || localStorage === null){
(function(){
function getExpiration(isRemove){
var date = new Date();
if(isRemove){
date.setTime((+date)-1000); //sometime in past
} else {
date.setTime((+date)+30758400000); //356 days ahead
}
//sample proxy server for node.js from http://www.catonmat.net/http-proxy-in-nodejs
var http = require('http');
http.createServer(function(request, response) {
var proxy = http.createClient(80, request.headers['host'])
var proxy_request = proxy.request(request.method, request.url, request.headers);
proxy_request.addListener('response', function (proxy_response) {
proxy_response.addListener('data', function(chunk) {
response.write(chunk);
#from http://www.sergeychernyshev.com/blog/speed-up-your-site-drop-in-htaccess-file/
<IfModule mod_deflate.c>
# Insert filter
SetOutputFilter DEFLATE # Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html # Don't compress images
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
@wavded
wavded / Arc.js
Created March 15, 2011 17:00
Arc.js
/**
* Arc model
*
* @module Arc
* @requires mongoose (npm install mongoose)
* @requires User (models/User.js)
* @global mongoose
*/
var Schema = mongoose.Schema,
User = require('./User.js');
@wavded
wavded / gist:961713
Created May 8, 2011 21:42
functions
function render(view,locals){
return function(req,res){
res.render(view,locals || {});
};
}
var render = #(view,locals){
return #(req,res){
res.render(view,locals || {});
}
@wavded
wavded / gist:1067909
Created July 6, 2011 18:08
npm error
info it worked if it ends with ok
verbose cli [ 'node', '/usr/local/bin/npm', 'install' ]
info using npm@1.0.15
info using node@v0.4.8
verbose config file /home/jdevries/.npmrc
verbose config file /usr/local/etc/npmrc
silly testEngine { author: { name: 'Marc Harter', email: 'wavded@gmail.com' },
silly testEngine name: 'rowe-law',
silly testEngine version: '0.0.1',
silly testEngine repository: { url: '' },
@wavded
wavded / populate.coffee
Created November 8, 2011 17:22
Populate a users contacts - works in 2.3.9 but not in 2.3.10
#!/usr/bin/env coffee
global.mongoose = require 'mongoose'
mongoose.connect 'mongodb://localhost/test'
Schema = mongoose.Schema
User = new Schema
userId : { type: String, index: true, required: true }
contacts : [ { type: Schema.ObjectId, ref: 'User' } ]
@wavded
wavded / contact.coffee
Created November 9, 2011 16:37
Pushing a contact (tested against mongoose 2.3.11)
#!/usr/bin/env coffee
global.mongoose = require 'mongoose'
mongoose.connect 'mongodb://localhost/test'
Schema = mongoose.Schema
User = new Schema
userId : { type: String, index: true, required: true }
contacts : [ { type: Schema.ObjectId, ref: 'User' } ]
@wavded
wavded / gist:1515551
Created December 23, 2011 22:29
Installing MongoDB on Ubuntu Server and Desktop

Edit /etc/apt/sources.list and add the following lines to the bottom of the file:

# MongoDB
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

Then run the following commands: