Skip to content

Instantly share code, notes, and snippets.

View fedesilva's full-sized avatar
👁️‍🗨️

federico silva fedesilva

👁️‍🗨️
View GitHub Profile
/* Recursively compose an arbitrarily long list of functions into a single function. */
function compose() {
/* One function, nothing to compose. */
if(arguments.length == 1)
return arguments[0];
else {
/* Compose the head with the immediate successor. */
var args = arguments;
/* The composition: f(g(x)) */
var f = [function() {
public class Foo {
public String theCurrentWay(SomeData data) {
if (data.getFoo() != null) {
if (data.getFoo().getBar() != null) {
if (data.getBlah() != null) {
return data.getFoo().getBar().getBlah().toString();
}
}
}
return null;
config.action_controller.asset_host = Proc.new do |source, request|
non_ssl_host = "http://asset#{source.hash % 4}.backpackit.com"
ssl_host = "https://asset1.backpackit.com"
if request.ssl?
case
when source =~ /\.js$/
ssl_host
when request.headers["USER_AGENT"] =~ /(Safari)/
non_ssl_host
// A simple trait:
trait CascadingActions {
implicit def tToActioneerT[T](t: T) = Actioneer(t)
case class Actioneer[T](tee: T) {
def withAction(action: (T => Unit)): T =
withActions(action)
def withActions(actions: (T => Unit)*): T = {
// Welcome to Scala version 2.7.5.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_20).
// Type in expressions to have them evaluated.
// Type :help for more information.
scala> import dispatch._
import dispatch._
scala> import oauth._
import oauth._
(ns com.freiheit.clojure.appengine.appengine-local
(:use
[compojure.http routes servlet helpers]
clojure.contrib.test-is
compojure.server.jetty
[clojure.contrib def str-utils duck-streams])
(:require
[clojure.contrib.logging :as log])
(:import
[com.google.appengine.api.labs.taskqueue.dev LocalTaskQueue]
(defproject compojureongae "0.2.0"
:description "Example app for deployoing Compojure on Google App Engine"
:namespaces [compojureongae.core]
:dependencies [[compojure "0.4.0-RC3"]
[ring/ring-servlet "0.2.1"]
[hiccup "0.2.4"]
[appengine "0.2"]
[com.google.appengine/appengine-api-1.0-sdk "1.3.4"]
[com.google.appengine/appengine-api-labs "1.3.4"]]
:dev-dependencies [[swank-clojure "1.2.0"]
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
==> manifest.json <==
{
"name": "GitHub Tweaks",
"version": "0.1",
"description": "Style tweaks for github pages",
"content_scripts": [
{
"matches": ["https://github.com/*", "https://gist.github.com/*"],
"css": ["tweaks.css"]
}