Skip to content

Instantly share code, notes, and snippets.

View davemo's full-sized avatar
😀

David Mosher davemo

😀
View GitHub Profile
@davemo
davemo / this.problem.txt
Created March 31, 2012 16:04
Crockford on the "This" problem in JavaScript
When a function is called with the function invocation pattern, its this is not bound to the outer
function’s this as we would hope, but is instead bound to the global object, which is horrible.
The workarounds for this include the use of bind functions and riddles like:
var that = this;
~ Douglas Crockford (http://www.yuiblog.com/blog/2012/03/30/what-is-the-meaning-of-this)
@davemo
davemo / howto.git.on.windows.7.txt
Created September 21, 2012 17:16
Git on Windows 7
My Dev Workflow from OS X on Windows 7
1. Install Console 2 and configure as per http://www.hanselman.com/blog/Console2ABetterWindowsCommandPrompt.aspx
You can skip the steps on Tabs and Powershell, but I do like his fancy icons :)
2. Install Git for windows http://git-scm.com/download/win
Now comes the fun part, after you have configured Console2 and installed the Windows git binary you'll want to link the Console2 tab that opens such that it is in the context of the git-bash cmd, how do we do this? Easy:
@davemo
davemo / README.md
Last active September 14, 2018 00:33
A pre-commit hook for git running on OS X to abort if it detects keywords in specified files (this version is setup for .coffee and .js files).

Git pre-commit Hooks

The pre-commit file listed here is setup to scan files for invalid keywords prior to commit to avoid debug or logging information making its way into production files. Right now it is setup to scan only .js and .coffee files for the following keywords:

KEYWORDS_REGEX="console\.(debug|info|log|warn)\(|alert\(|debugger"
EXTENSIONS_REGEX="(.js$|.coffee$)"

Installing the Hook

@davemo
davemo / Anonymous Function Testing.js
Created February 9, 2011 17:46
A pattern for testing anonymous functions and asserting expected behaviour through nested calls using JasmineBDD.
// Notes: This is a way @Searls and I came up with that lets you
// test deeply nested anonymous functions and callbacks.
// We don't recommend nesting things this deep but we _do_ like the closure scoping in the tests.
// Any suggestions or improvements would be welcome :)
// The Codez, A little modal window framework
(function($, _) {
$.cil = $.cil || {};
@davemo
davemo / deconstruct-2018-takeaways.md
Last active May 29, 2018 20:59
I have a list of short takeaways from each talk that capture the most valuable lesson for me.

Allison Parrish: There is great beauty in applying scientific concepts (interpolation) and the scientific method to domains that we wouldn't normally think to (syntax, grammar, poetry).

Anjana Vakil: Language matters, and has historically evolved to meet the needs of its speakers; we need to be better at helping the language in the domain of computing evolve beyond where it is currently being held back.

Augie Fackler: API design can (and should) be decoupled from API implementation; this decoupling can provide a valuable articulation point that yields flexibility in the right areas without compromising on principles.

Elle Vargas: We need to embrace the technical neophytes (or Juniors) mindset in our organizations, because they are best equipped to bridge the gap between people with little to no technical background and experts; failure to do this leads to security compromises on the scale of the manipulation of democracy.

Gary Bernhardt: The technical community needs to be aware of the altruisti

@davemo
davemo / forward-js-talk-notes.md
Last active April 25, 2018 15:33
My Notes for talks from ForwardJS Ottawa 2018

ForwardJS Ottawa, April 4/5, 2018

Essentialism

Andy Mockler (@asmockler), Shopify Analytics Team, Chicago

inspirational sources:

  • book: Essentialism by Greg McKeown

key concepts:

  • essentialism is about getting the right things done
@davemo
davemo / posterous-convert.sh
Last active December 2, 2017 11:20
Converts official posterous archive files from HTML to Markdown
#!/bin/bash
##### DESCRIPTION
# Convert all HTML files in the posterous backup directories into Markdown.
# This script works with the official backup that you can download from Posterous.
# Modified by @davemo using code from @rdegges https://github.com/rdegges/posterous-to-markdown
# which was written for a 3rd party backup tool.
@davemo
davemo / skeleton.html
Created November 6, 2010 04:13
A base to play with, really impressive :P
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Skeletons Are Scary</title>
</head>
<body>
</body>
</html>
@davemo
davemo / bootstrap.js
Last active November 16, 2017 13:23
injectorsauce
(function() {
var $injector = angular.injector(['ng']);
$injector.invoke(function($http) {
// this works!
$http.get("/auth/csrf_token").then(function(response) {
angular.module("app").constant("CSRF_TOKEN", response.csrf_token);
angular.bootstrap(document, ['app']);
});

Keybase proof

I hereby claim:

  • I am davemo on github.
  • I am dmosher (https://keybase.io/dmosher) on keybase.
  • I have a public key ASAjl7nZA81gfQd-iomz3uGBjmQfBlYnEOEnehGNxILLGgo

To claim this, I am signing this object: