Skip to content

Instantly share code, notes, and snippets.

@jakejscott
jakejscott / Dish.coffee
Created July 7, 2011 08:27
Inheritance in CoffeeScript
window.Dish = class Dish
constructor: (rawDescription="") ->
@title = rawDescription.match(/([^$]+)/)?[1]?.trim()
hello: ->
alert('I am a yummy ' + @title)
window.YummyDish = class YummyDish extends Dish
hello: ->
@jakejscott
jakejscott / main.Lua
Created July 19, 2011 16:07
Nom nom iPhone app written in Corona SDK
local _H = display.contentHeight;
local _W = display.contentWidth;
local monster = display.newText("a", 0, 0, "Monsterz", 120);
monster.x = _W * 0.5; monster.y = _H * 0.5;
local hello = display.newText("Tap me, I'z hungree", 0, 0, "BorisBlackBloxx", 24);
hello.x = _W * 0.5; hello.y = (_H * 0.5) + 80;
local nom = display.newText("Nom nom", 0, 0, "BorisBlackBloxx", 12);
@jakejscott
jakejscott / TinyIoc Nube.cs
Created August 31, 2011 15:28
TinyIoc Nube
public class Bootstrapper : DefaultNancyBootstrapper
{
protected override void InitialiseInternal(TinyIoCContainer container)
{
base.InitialiseInternal(container);
FormsAuthentication.Enable(this, new FormsAuthenticationConfiguration()
{
RedirectUrl = "~/login",
UsernameMapper = container.Resolve<IUsernameMapper>()
@jakejscott
jakejscott / MongoCache.cs
Created October 5, 2011 15:01
Lightspeed ORM second level cache using MongoDB (Doesn't support expirying items yet..todo)
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Loot.Logging;
using Mindscape.LightSpeed.Caching;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
namespace Loot
{
@jakejscott
jakejscott / BrowserContextExtenstions.cs
Created October 24, 2011 16:19
Nancy Auth Cookie, bit of a hack but works and uses the least amount of code.
using System;
using System.Collections.Generic;
using Nancy.Authentication.Forms;
using Nancy.Testing;
namespace Nancy.Authentication.Forms
{
public static class BrowserContextExtenstions
{
public static void FormsAuth(this BrowserContext browserContext, Guid userIdentifier)
@jakejscott
jakejscott / DateTimeExtensions.cs
Created October 26, 2011 15:07
Date time extension ToVerbalTimeSince
using System;
namespace Devastator
{
public static class DateTimeExtensions
{
/// <summary>
/// Converts a DateTime compared to the current time into plain english for explaining how recently the datetime occurred in the past.
/// </summary>
public static string ToVerbalTimeSince(this DateTime sourceDateTime)
@jakejscott
jakejscott / gist:1626646
Created January 17, 2012 13:35
940px wide 4 column grid using negative margins
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div id="wrapper">
<div class="clearfix">
Before Grid
@jakejscott
jakejscott / gist:1626709
Created January 17, 2012 14:00
Wookmark style grid
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div id="wrapper">
<div class="clearfix">
Before Grid
@jakejscott
jakejscott / Init.js
Created March 29, 2012 08:09
Best jQuery plugin example yet
$(function() {
var $document = $(document);
$document.trigger('domloaded', $document);
$('.someselector').load('/my/url', function(nodes) {
$document.trigger('ajax_loaded', nodes);
});
});
@jakejscott
jakejscott / HtmlFormatter.cs
Created May 11, 2012 15:18
Asp.net web api, text/html, text/plain formatter
public class HtmlFormatter : MediaTypeFormatter
{
public HtmlFormatter()
{
SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain"));
}
protected override bool CanReadType(Type type)
{