Skip to content

Instantly share code, notes, and snippets.

View trevmex's full-sized avatar
👨‍👩‍👧‍👦

Trevor Menagh trevmex

👨‍👩‍👧‍👦
View GitHub Profile
@trevmex
trevmex / jasmine.nested_spies.spec.js
Created June 28, 2011 15:42
Nesiting spies to see if a callback in a deep nest has worked.
function nestedCallbacks(callback) {
console.log("start");
firstNest(function () {
secondNest(function () {
callback("test");
});
});
}
function firstNest(callback) {
/ Why Can't I Test My JavaScript?
%h3 #railsconf 2011 Notes
%i Greg Moeck (gregmoeck)
%p The Ruby community has made TDD/BDD accessible.
%p Why can't we do TDD/BDD inJavaScript?
%p What is the problem? There are LOTS of excuses:
%ul
%li The tools suck
%li The browser sucks
%li The DOM sucks
@trevmex
trevmex / jp.yml
Created May 25, 2011 13:19
Japanese locale for formtastic
jp:
formtastic:
:yes: 'はい'
:no: 'いいえ'
:create: '%{model}を作る'
:update: '%{model}をアップデートする'
:submit: '%{model}をサブミットする'
:required: '必要'
@trevmex
trevmex / gist:981210
Created May 19, 2011 16:48
intelligent discussion about gender issue in #railsconf
[11:53am] Dreamer3: More women this year than last
[11:53am] jumex: 2.5% of the conference!
[11:54am] Dreamer3: I need to find a career where men are in the minority
[11:54am] jumex: Hopefully more next year. We NEED more women in tech!
[11:55am] necromancer: they should call that movement to try and get more females into programming "boner-driven development"
[11:55am] mike-burns: Discussion gender in tech is tricky because someone always says a negatively-sexist remark within five minutes.
[11:56am] necromancer: mike-burns: do you think the fact that men outnumber women in tech is itself sexist?
[11:56am] necromancer: or merely a product of how men & women are handled in this country?
[11:56am] jumex: We are all sexists, but we have to realize it before we can control it.
[11:57am] jumex: mike-burns: I totally agree with you there.
@trevmex
trevmex / gist:965022
Created May 10, 2011 18:12
JavaScript template to make private functions testable
if (typeof NS === 'undefined' || !NS) {
var NS = {};
}
(function ($) {
NS.Klass = function(options) {
var settings = {
debug: false
},
private = {
@trevmex
trevmex / bst.js
Created February 11, 2011 05:38
A simple binary search tree in JavaScript
/*
* File: bst.js
*
* A pure JavaScript implementation of a binary search tree.
*
*/
/*
* Class: BST
*
// ==UserScript==
// @name Hide Unnessary Campfire Messages
// @namespace http://www.trevmex.com
// @description Hide everything but text messsages.
// @author Trevor Lalish-Menagh
// @homepage
// @include http*//*.campfirenow.com/room*
// ==/UserScript==
(function($) {
describe("myNS.log", function () {
it("sends a string to the console log", function () {
spyOn(window.console, "log");
expect(myNS.log("test message")).toEqual("test message");
expect(window.console.log).toHaveBeenCalledWith("test message");
});
});
myNS.caller = function () {
myNS.funct1();
myNS.funct2();
myNS.funct3();
};
/*
* user.watch v1.0: Cross-browser user.watch
* From http://code.eligrey.com/object.watch/
*
* By Elijah Grey, http://eligrey.com
* Tweaked by Trevor Lalish-Menagh, http://trevmex.com
*
* A shim that partially implements object.watch and object.unwatch
* in browsers that have accessor support.
*