Skip to content

Instantly share code, notes, and snippets.

@jabley
jabley / gist:1228867
Created September 20, 2011 11:05 — forked from marick/gist:1228842
(ns scratch.core
(:use midje.sweet
[clojure.set :only [union intersection difference]]
))
(def east [1 0])
(def north [0 1])
(def west [-1 0])
(def south [0 -1])
@jabley
jabley / partial_application.rb
Created September 19, 2011 06:08 — forked from headius/partial_application.rb
Partial application that works on all Ruby implementations
class Object
def _(name, *partial_args)
Proc.new do |*new_args|
send name, *partial_args.map {|arg| arg == :_ ? new_args.shift : arg}
end
end
end
# Practical examples:
[1,2,3].each &_(:puts, :_)
@jimweirich
jimweirich / y.coffee
Created September 18, 2011 22:11
Y Combinator Demo in CoffeeScript
# Y Combinator Demo in CoffeeScript
#
# Run with: coffee y.coffee
p = console.log
fact = (f) ->
(n) ->
if n==0
1
@josevalim
josevalim / rbx_partial_application.diff
Created September 17, 2011 20:59
Partial application on rubinius. Apply the diff to rubinius project and run `rake build`. Idea by @josevalim, code by @wycats.
diff --git a/lib/compiler/ast/transforms.rb b/lib/compiler/ast/transforms.rb
index 19e1cfb..4e52ec2 100644
--- a/lib/compiler/ast/transforms.rb
+++ b/lib/compiler/ast/transforms.rb
@@ -59,6 +59,71 @@ module Rubinius
end
end
+ # Provide an underscore node that allows partial application in Ruby.
+ # Instead of doing a method call, we are going to generate a lambda
@addyosmani
addyosmani / jQueryPluginPatterns.js
Created August 31, 2011 18:02
jQuery Plugin Patterns
/*
A (very) WIP collection of optimized/recommended jQuery plugin patterns
from @addyosmani, @cowboy, @ajpiano and others.
Disclaimer:
-----------------------
Whilst the end-goal of this gist is to provide a list of recommended patterns, this
is still very much a work-in-progress. I am not advocating the use of anything here
until we've had sufficient time to tweak and weed out what the most useful patterns
@calavera
calavera / gist:1172285
Created August 25, 2011 23:15
Java on Engine Yard's cloud

EXPERIMENTAL AND UNOFFICIAL, don't expect support of any type from Engine Yard on this. This is just a crazy idea that came to my mind a few weeks ago.

Application configuration

  1. Compile the java web application and create an "exploded" war file with any tool you like better, if you use maven you can run "mvn war:exploded".
  2. Create a git repository for your exploded web application and push the compiled code.
  3. Add those files to the root of your repository:
  4. Go to Engine Yard AppCloud's dashboard and press the button "Create New Application", add the git url for your repository, select "Rack" as application type and submit the form.
@addyosmani
addyosmani / codereview.md
Created August 25, 2011 12:11
Lessons from a JavaScript code review

#Lessons From A JavaScript Code Review

I was recently asked to review some code for a new JavaScript application and thought I might share some of the feedback I provided as it includes a mention of JavaScript fundamentals that are always useful to bear in mind. Code reviews are possibly the single biggest thing you can do to improve the overall quality of your solutions and if you're not actively taking advantage of them, you're possibly missing out on bugs you haven't noticed being found or suggestions for improvements that could make your code better.

##Challenges & Solutions

Code reviews go hand-in-hand with maintaining strong coding standards. That said, standards don't usually prevent logical errors or misunderstandings about the quirks of a programming language. Even the most experienced developers can make these kinds of mistakes and code reviews can greatly assist with catching them.

Often the most challenging part of code reviews is actually finding an experienced developer you trust to complete

@headius
headius / build.sh
Created August 16, 2011 02:27
Building the Hotspot compiler team's Hotspot branch alone
#!/bin/sh
# This script is for building the hsx/hotspot-comp branch in isolation.
#
# Prerequisites:
# * appropriate build tools
# * a working Sun Java 6 build (i.e. JDK6) is available at:
# HOME/java/re/j2se/1.6.0/latest/binaries/linux-[i586/amd64]
# * a working Sun Java 7 build (i.e. JDK7) is available at:
# HOME/java/re/j2se/1.7.0/latest/binaries/linux-[i586/amd64]
# HOME/java/re/j2se/1.7.0/promoted/latest/binaries/linux-[i586/amd64]
@mnot
mnot / sun buffering goes wild
Created August 11, 2011 02:32
The raw HTTP of a GET response from http://www.sun.com/ (before the Oracle acquisition), reproduced here in its entirety.
HTTP/1.1 200 OK
Server: Sun-Java-System-Web-Server/7.0
Date: Mon, 07 Dec 2009 07:25:34 GMT
P3p: policyref="http://www.sun.com/p3p/Sun_P3P_Policy.xml", CP="CAO DSP COR CUR ADMa DEVa TAIa PSAa PSDa CONi TELi OUR SAMi PUBi IND PHY ONL PUR COM NAV INT DEM CNT STA POL PRE GOV"
Cache-control: public
Set-cookie: JROUTE=W2VMz2yu926eYGvP; Path=/
X-powered-by: JSP/2.1
Set-cookie: JSESSIONID=80765ae114eab08df95a11208c62; Path=/
Content-type: text/html;charset=UTF-8
Via: 1.1 https-www
@cowboy
cowboy / ba-detach.js
Created April 23, 2011 16:43
JavaScript detach: detach a node from the DOM, optionally reattaching it when done.
/*!
* JavaScript detach - v0.2 - 5/18/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
function detach(node, async, fn) {