Skip to content

Instantly share code, notes, and snippets.

View geddski's full-sized avatar

Dave Geddes geddski

View GitHub Profile
alert('test mercutio');
@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"/>
alert('ha!');
/*
How to use Angular inside a Backbone view.
*/
var ViewWithAngular = Backbone.View.extend({
render: function(container){
var $injector = angular.injector(['ng', 'mason']);
$injector.invoke(function($rootScope, $compile){
var elem = $compile('<h1 ng-controller="NestedCtrl">Backbone View with nested Angular. Message: {{message}}</h1>')($rootScope);
@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' });