Skip to content

Instantly share code, notes, and snippets.

@jonschoning
jonschoning / about.md
Created August 10, 2011 02:13 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
// A RequireJS module that wraps the jQuery UI Dialog in a jQuery.Deferred
// Advantages:
// Reuses a single DOM element for all the dialogs
// Keeps the dialog out of the DOM when it is not in use
// A much more elegant interface for using custom modals and working with the user's resolution
define("bocoup.confirm",["jquery.ui.widget"],function(factory,position,dialog) {
var d = $("<div>"),
defaults = {
title:"Confirmation"
@jonschoning
jonschoning / gist:1553563
Created January 3, 2012 05:00 — forked from fennb/gist:1124535
node.js proxy server in 20 lines of JS (via http://www.catonmat.net/http-proxy-in-nodejs/)
var http = require('http');
http.createServer(function(request, response) {
var proxy = http.createClient(80, request.headers['host'])
var proxy_request = proxy.request(request.method, request.url, request.headers);
proxy_request.addListener('response', function (proxy_response) {
proxy_response.addListener('data', function(chunk) {
response.write(chunk, 'binary');
});
proxy_response.addListener('end', function() {
@jonschoning
jonschoning / hack.sh
Created March 31, 2012 20:15 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@jonschoning
jonschoning / CookieTempDataProvider.cs
Created April 17, 2012 03:17 — forked from friism/CookieTempDataProvider.cs
CookieTempDataProvider for ASP.NET
/*
To use the provider, you must override this method in your controllers:
protected override ITempDataProvider CreateTempDataProvider()
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Web;
using System.Web.Mvc;
namespace AppHarbor.Web.Mvc
// Is the passed CSS property supported?
// eg. detectCSS('transition')
function detectCSS(prop){
var
prop = prop.replace(/-(\w)/g,function(s,g){return g.toUpperCase()}),
pre = ',Icab,Khtml,Moz,Ms,O,Webkit'.split(',');
for (var i = 0; i < pre.length; ++i){
if(i==1)
prop = prop.slice(0,1).toUpperCase() + prop.slice(1);
function sequence_(lst)
{
function do_it(i) {
if (i === lst.length)
return;
lst[i](function() {
do_it(i+1);
});
}
do_it(0);
object FizzBuzz extends App {
val nones = Stream.continually(None)
val fizzes: Stream[Option[String]] = nones.take(2) ++ Some("Fizz") #:: fizzes
val buzzes: Stream[Option[String]] = nones.take(4) ++ Some("Buzz") #:: buzzes
for (((fizz, buzz), n) <- fizzes zip buzzes zip (1 to 100)) {
println(fizz.map(_ + buzz.getOrElse("")).orElse(buzz).getOrElse(n))
}