This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Pong<T> {} | |
class Ping<T> implements Pong<Pong<? super Ping<Ping<T>>>> { | |
static void Ping() { | |
Pong<? super Ping<Long>> Ping = new Ping<Long>(); | |
} | |
} | |
> javac Ping.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn scaffold | |
"Print the ancestor method signatures of a given interface." | |
[iface] | |
(doseq [[iface methods] (->> iface | |
.getMethods | |
(map #(vector (.getName (.getDeclaringClass %)) | |
(symbol (.getName %)) | |
(count (.getParameterTypes %)))) | |
(group-by first))] | |
(println (str " " iface)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For each Ruby module/class, we have Ruby methods on the left and the equivalent | |
Clojure functions and/or relevant notes are on the right. | |
For clojure functions, symbols indicate existing method definitions, in the | |
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can | |
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master, | |
ruby-to-clojure.*/* functions can be obtained from the source files in this | |
gist. | |
If no method symbol is given, we use the following notation: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'clojure.test) | |
; Source: https://gist.github.com/mybuddymichael/4425558 | |
(defmacro spec | |
[name-string & body] | |
(let [name-symbol | |
(-> name-string | |
clojure.string/lower-case | |
(clojure.string/replace #"\W" "-") | |
(clojure.string/replace #"-+" "-") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Gives warning: Assert failed.... | |
(ns light.core | |
(:use [clojure.pprint])) | |
(def p pprint) | |
(+ 1 1) | |
(def x (into {} (map (fn [x] [x (inc x)]) (take 1000 (range))))) | |
(pprint x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export BUNDLE_GEMFILE=CapGemfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro class [name] | |
`(set! ~name | |
(do (defn ~name []) ~name )) | |
) | |
(class A) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="underscore-min.js"></script> | |
<script src="http://connect.soundcloud.com/sdk.js"></script> | |
</head> | |
<body> | |
<h1>My Amazing Underscore project</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# trap "kill -- -$BASHPID" SIGINT SIGTERM EXIT | |
trap 'exit 42' SIGINT SIGQUIT SIGTERM | |
function sayit() { | |
while [[ 1 ]] | |
do echo oi | |
sleep 1 | |
done | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function draw(ctx, f, width, height) { | |
var y; | |
var ch = height/2; | |
var cw = width/2; | |
ctx.beginPath(); | |
ctx.moveTo(0, ch-f(-width)); | |
for (var x=-width+1; x<width; x++) { | |
y = ch-f(x); | |
ctx.lineTo(x+cw, y); | |
} |
OlderNewer