Skip to content

Instantly share code, notes, and snippets.

View jgable's full-sized avatar

Jacob Gable jgable

  • Making Other People Money
  • San Carlos, CA
  • X @jacob4u2
View GitHub Profile
@jgable
jgable / prototypeClass.js
Created April 18, 2012 23:21
minimum JS - Classes 2
// The classical prototype way
/* Define a constructor */
function Baby(name, sex, says) {
// Set some variables on the object
this.name = name;
this.sex = sex;
this.says = says;
}
@jgable
jgable / quickClass.js
Created April 18, 2012 23:19
Minimum JS - Classes 1
// The quick and dirty way
var baby1 = {
name: "cutesy",
sex: "F",
speak: function() {
return "gaga"; // As in Lady
}
};
// Functionally equivalent to this...
@jgable
jgable / timerPageSnip-Bug.js
Created March 8, 2012 01:07
Magnitude Blog Post Code
SurveyTimersPage.prototype.updateTimerQuestionResponse = function () {
var newResponseId = null;
if (this.timerMgr.hasValuesEntered()) {
// Update this questions response to the timer measurement response.
var resp = this.surveyMgr.getCorrectResponse(this.timerQuestion.AllowableValues);
if (resp !== null) {
newResponseId = resp.id;
@jgable
jgable / securing_rails_updates.md
Created March 6, 2012 04:58 — forked from peternixey/securing_rails_updates.md
How Homakov hacked GitHub and how to protect your application

##How Homakov hacked GitHub and the line of code that could have prevented it


Please note: THIS ARTICLE IS NOT WRITTEN BY THE GITHUB TEAM or in any way associated with them. It's simply hosted as a Gist because the markdown formatting is excellent and far clearer than anything I could manage on my personal Tumblr at peternixey.com.

If you'd like to follow me on twitter my handle is @peternixey


@jgable
jgable / CacheManifestResult.cs
Created February 25, 2012 14:02
MVC 3 Cache manifest result
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
/// <summary>
/// Contains information about a cache manifest file to be generated. see http://www.html5rocks.com/en/tutorials/appcache/beginner/
/// </summary>
public class CacheManifest
{
@jgable
jgable / AllowJsonGetAttribute.cs
Created February 10, 2012 20:12
AllowJsonGetAttribute for .Net MVC
// Originally from RealWorldWpDev.codeplex.com : @matthidinger
using System.Web.Mvc;
public class AllowJsonGetAttribute : ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
var result = filterContext.Result as JsonResult;
if(result != null)
@jgable
jgable / NumberHelpers.cs
Created January 27, 2012 01:33
NumberHelpers - Fibonacci Sequence, Primes, IsPrime, Triangles and Pythagoreans
using System;
using System.Collections.Generic;
public static class NumberHelpers
{
/// <summary>
/// Returns a sequence of fibonacci numbers.
/// </summary>
/// <returns></returns>
public static IEnumerable<long> Fibonacci()
@jgable
jgable / membershiptables.sql
Created December 23, 2011 02:43
aspnet_regsql membership scripts
/*************************************************************/
/*************************************************************/
/*************************************************************/
-- Create the temporary permission tables and stored procedures
-- TO preserve the permissions of an object.
--
-- We use this method instead of using CREATE (if the object
-- doesn't exist) and ALTER (if the object exists) because the
-- latter one either requires the use of dynamic SQL (which we want to
@jgable
jgable / ModuleExport.js
Created October 18, 2011 05:33
Modern Web Development Blog Post code - Module Export Pattern
// Initialize our apps namespace; add a pages holder for later.
var MYAPP = {
pages: {}
};
// A closure to encapsulate our HomePage class.
(function($, app) {
// This little guy is private to this closure.
function bindButtons($page) {
@jgable
jgable / jQueryGems.js
Created October 18, 2011 05:32
Modern Web Development Blog Post code - jQuery Gems
var nums = [1,2,3,4,5,6,7,8,9,10];
// $.each is a simple foreach helper
$.each(nums, function() { if(this % 2 === 1) { log("Found an odd number"); });
// $.grep is a filter for a list
var odds = $.grep(nums, function() { return this % 2 === 1; });
// $.map is a projection of a list
var labels = $.map(nums, function() { return "Number " + this; });