Skip to content

Instantly share code, notes, and snippets.

View davidpadbury's full-sized avatar

David Padbury davidpadbury

View GitHub Profile
@davidpadbury
davidpadbury / normal.js
Created February 3, 2011 14:44
jQuery Hover example
// $(fn) shorthand for $(document).ready(fn)
$(function() {
// Hover is a handy $ function that takes two functions, the first for when the mouse goes in and the other for when it goes out
$('.navcontainer li').hover(function() {
// this in a $ event handler will refer to the element raising the event
$('.' + this.id).addClass('thecolor');
}, function() {
$('.' + this.id).removeClass('thecolor');
});
});
@davidpadbury
davidpadbury / spec.coffee
Created January 13, 2011 18:53
Comparison of Jasmine spec in CoffeeScript and JavaScript
describe "when doing something", ->
it "should do something else", ->
expect(something).toEqual 42
@davidpadbury
davidpadbury / Output.txt
Created January 13, 2011 03:11
Querying NetFlix with a DataSvcUtil client
Gay
Golf
IMAX
Iran
LOGO
Math
Pets
Pop
Yoga
@davidpadbury
davidpadbury / yepnope-wait.js
Created October 25, 2010 01:24
yepnope wait order
yepnope([
{
load: 'http://code.jquery.com/jquery-1.4.3.min.js',
callback: function(){}
},
{
test: Modernizr.input.placeholder,
nope: 'js/jquery.placeholder.js',
callback: function(inc, testResult) {
$('input, textarea').placeholder();
void Main()
{
var testMock = new Mock<Test>();
testMock.SetupGet(m => m.IsSomething).Returns(true);
var test = testMock.Object;
Debug.Assert(test.IsSomethingTrue);
}
var http = require('http'),
parse = require('url').parse,
spawn = require('child_process').spawn;
this.server = http.createServer(function(request, response){
var url = parse(request.url, true),
convert = spawn('convert', ['chart.svg', 'png:-']);
response.writeHeader(200, {'Content-Type': 'image/png'});
(function($) {
ProvenWorks.IndustryComplete.StaggeredEvent = function(method, options) {
var self = this;
var timerId;
var method = method;
var settings = $.extend({
delay: 200
}, options);
self.trigger = function() {
if (typeof(ProvenWorks) === 'undefined') var ProvenWorks = {};
(function($) {
ProvenWorks.IndustryComplete = new function() {
var self = this;
function buttonClicked() {
alert("You've clicked a button!");
};
void Main()
{
Person pete = new PersonFactory().GetPerson(1);
Console.WriteLine(pete.Name);
}
public class Person
{
public virtual int Id { get; protected set; }
void Main()
{
var name = new LazyValue<string>(LoadName); // Technically you don't even need the generic specification here but I'm being verbose
Console.WriteLine(name.Value);
}
private static string LoadName()
{
return "Pete Smith";