Skip to content

Instantly share code, notes, and snippets.

View barnabyc's full-sized avatar

Barnaby Claydon barnabyc

  • Boston, MA
  • 09:17 (UTC -04:00)
View GitHub Profile
// Exercise 2 - Closures
// Wrap the following code in a closure and export only the "countdown" function.
// Code
var foo = (function(){
var index;
function log(){
(function(){
var index;
function log(){
console.log(index);
}
function iterate(){
log();
// 1. Write a class to support the following code:
var Person = funcion(name) {
this.name = name;
};
var thomas = new Person('Thomas');
var amy = new Person('Amy');
thomas.name // --> "Thomas"
// 1. Write a class to support the following code:
var Person = funcion(name) {
this.name = name;
};
var thomas = new Person('Thomas');
var amy = new Person('Amy');
thomas.name // --> "Thomas"
function cachedSin(num) {
this.cache = this.cache || {};
if(this.cache[num] != null) {
console.log('returning from cache...');
return this.cache[num];
}
return this.cache[num] = Math.sin(num);
}
<div id="the_div">
<ul id="the_list">
<li id="the_item">Click me!</li>
</ul>
</div>
<p id="log"></p>
<script type="text/javascript" charset="utf-8">
function log(string){
@barnabyc
barnabyc / donut-halos.html
Created October 11, 2012 21:48
d3 donut charts with halo data
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Multiple Pie Charts</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.4.5"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.4.5"></script>
<style type="text/css">
body { text-align: center }
path { stroke: #fff; stroke-width: 4px; }
var request = new Y.JSONPRequest(toolBarUri, {
on: {
success: Y.bind(function(response) {
Y.log("Parsing toolbar configuration", 'info', 'modelDashboard');
return response;
}, this),
failure: Y.bind(function(e) {
Y.log("Failed to get toolbar for dashboard.", "error", "modelDashboard");
Running Primrose specs
--------------------------
-=> enter, level: 0
Matchers
-=> enter, level: 1
toBe
-=> enter, level: 2
it asserts simple matches
-=> enter, level: 3
beforeEach
using System.Html;
using System.Runtime.CompilerServices;
using jQueryApi;
[Mixin("$.fn")]
public static class TextPreviewerjQueryPlugin
{
public static jQueryObject TextPreviewerjQuery(TextPreviewerjQueryOptions options)
{
return jQuery.Current.Each(delegate(int i, Element element)
{