This gist is aimed at helping you assess whether you'll be a good fit for Bocoup's "Foundations of Programming with JavaScript" training. This class is aimed at introducing you to fundamental concepts of development using JavaScript. In this class, you'll work through the process of building a simple game of hangman; along the way, you'll learn about functions, arrays, objects, and prototypes, and get a brief introduction to the jQuery library. You'll also learn about approaches that will help you write more maintainable code, and get introduced to tools for debugging and testing your JavaScript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grunt.initConfig({ | |
foo: { | |
_options: { | |
param: 'default' | |
}, | |
bar: {}, | |
baz: { | |
_options: { | |
param: 'override default' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Object#forIn, Object#forOwn | |
* | |
* Copyright (c) 2012 "Cowboy" Ben Alman | |
* Licensed under the MIT license. | |
* http://benalman.com/about/license/ | |
*/ | |
Object.defineProperties(Object.prototype, { | |
forIn: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
module.exports = function(grunt) { | |
function readOptionalJSON(filepath) { | |
var data = {}; | |
try { | |
data = grunt.file.readJSON(filepath); | |
grunt.log.write('Reading data from ' + filepath + '...').ok(); | |
} catch(e) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<iros> qunit question - I have some behavior I want to test that is only important before DOM ready... is there a way to do that with qunit? | |
<tbranyen> iframe | |
<danheberden> ditto | |
<ben_alman> ditto to whom | |
<danheberden> it that isn't apparent, then it's of no consequence | |
<ben_alman> stop avoiding the question | |
<danheberden> avoidance is only discerned when the answer sought isn't received | |
<ben_alman> ditto my previous statement; also note the qualification of said ditto | |
<iros> lol | |
<ben_alman> ditto, iros |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Abstraction.js | |
* | |
* Copyright (c) 2012 "Cowboy" Ben Alman | |
* Licensed under the MIT license. | |
* http://benalman.com/about/license/ | |
*/ | |
var Abstraction = (function($) { | |
var _ = $.prototype; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://twitter.com/cowboy/status/205726591622463488 | |
// http://twitter.com/cowboy/status/205726020026904579 | |
Whee (function(p,q,r){r=p[q];p[q]=function(){return Math.random()<0.9?r.apply(this,arguments):'[object WAT]'}}(Object.prototype,'toString')) | |
// http://twitter.com/cowboy/status/196967238710992896 | |
You know what sucks? function F(){} var f = new F(); F.prototype = {}; f instanceof F // false #javascript | |
// http://twitter.com/cowboy/status/196961893502566400 | |
Fun with functions: '$'.constructor((new(new(new(new(new function $(){$.prototype.$=$.toString=$;return':)'}).$).$).$).$).$) #javascript |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Coders, if your goal is to align foo and bar, using a <tab> character is | |
// incorrect. If your goal, however, is to create an additional level of | |
// indentation, then go you. Either way, with a tab size other than 4, this | |
// looks like shit. | |
var foo = 1, | |
bar = 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For Gianni | |
String.prototype.indexOfSplit = function(separator, n) { | |
var str = String(this); | |
var result = []; | |
var position; | |
while (str && --n > 0) { | |
position = separator === '' ? 1 : str.indexOf(separator); | |
if (position === -1) { | |
result.push(str); |
Getting grunt to work with Cygwin and git on Windows is a bit difficult considering the cygwin package that is installed by git has an outdated version of node running on it. There are several issues to work through:
- Cygwin by default installs an old version of node.
- Open Cygwin shell
which node
tells you where the executable isnode --version
tells you if it's oldcd
to the directory listed bywhich node
mv node.exe node.exe.bak
- download node from nodejs.org and install it
- Node installed through installer doesn't update PATH to point to correct version of node installed normally.