Skip to content

Instantly share code, notes, and snippets.

View geddski's full-sized avatar

Dave Geddes geddski

View GitHub Profile
@geddski
geddski / service-demystification-test.js
Created June 19, 2013 16:40
Demystification of Angular's services.
var expect = chai.expect;
describe('services', function(){
var goat, monkey, monkey2, Donkey, tiger1, tiger2, lion;
beforeEach(function(){
//load the module
module('app');
//configure providers
<h1>Inner</h1>
<img src="http://www.21stcenturytiger.org/wp-content/blogs.dir/2/files/home-page/malayan_adrianotavano_zoomaimi2_2012.jpg"/>
@geddski
geddski / twilio.xml
Last active December 12, 2015 07:28
<Response>
<Play>http://stark-eyrie-7115.herokuapp.com/cmm.mp3</Play>
</Response>
@geddski
geddski / oo-pattern.js
Created January 8, 2013 08:53
Pattern for Object Oriented JavaScript. You can run these tests with Mocha and play around with it. You'll need node installed, and then install should (locally) and mocha (globally): 1. download oo-pattern.js somewhere (~/js for example) 2. $cd ~/js 3. npm install should 4. $npm install -g mocha 5. mocha oo-pattern.js NOTE: I think inheritance …
/* Pattern for OOP in JavaScript */
//TODO see if safe way to add inheritsFrom to Function
var should = require('should');
function inherit(C, P){
var F = function(){}; //intermediary function between Parent and Child
F.prototype = P.prototype; //link intermediary function to Parent
var funcs = C.prototype; //keep track of any existing functions on the Child prototype
C.prototype = new F(); //link child to intermediary function
for (var attrname in funcs) {
@geddski
geddski / Preferences.sublime-settings
Created January 4, 2013 04:45
my sublime settings
{
"caret_style": "wide",
"color_scheme": "Packages/Color Scheme - Default/GrandsonOfObsidian.tmTheme",
"font_face": "Source Code Pro light",
"font_size": 19.0,
"ignored_packages":
[
"Vintage"
],
"save_on_focus_lost": true,
@geddski
geddski / express.js
Created December 14, 2012 23:40
example of using express middleware to gzip xml files
var express = require('express');
var connect = require('connect');
var zlib = require('zlib');
var fs = require('fs');
var app = express();
var compressOptions = {
filter: function(req, res) {
return /json|text|xml|javascript/.test(res.getHeader('Content-Type'))
}
@geddski
geddski / manual.js
Created December 14, 2012 23:38
example of gzipping files manually in Node
var http = require('http');
var fs = require('fs');
var zlib = require('zlib');
http.createServer(function (req, res) {
// var img = fs.readFileSync('./bird.jpg');
var img = fs.createReadStream('./public/bird.jpg');
// res.writeHead(200, {'Content-Type': 'image/jpeg'});
res.writeHead(200, { 'content-encoding': 'gzip' });
{
"bg" : "purple",
"spacing" : 0,
"gutter" : "10px",
"queries": {
"small": "screen and (min-width:1px) and (max-width:400px)",
"large": "screen and (min-width:1501px)"
},
"animate": {
"special": {
@geddski
geddski / base.css
Created August 2, 2012 19:11
mobile (base) stylesheet example
body{
background: orange;
}
@geddski
geddski / npminstall.js
Created March 16, 2012 19:35
test programmatic npm install
var npm = require('npm');
npmInstall(['http://dl.dropbox.com/u/3098507/sample.tar.gz'], function () {
console.log('yay');
});
/*
programmatically install some libs with npm
working in OSX but not windows
*/
function npmInstall(libs, callback){