Skip to content

Instantly share code, notes, and snippets.

View danielribeiro's full-sized avatar

Daniel Ribeiro danielribeiro

View GitHub Profile
@danielribeiro
danielribeiro / gist:1387721
Created November 23, 2011 02:04 — forked from etorreborre/gist:1387113
An example of a non-terminating compilation with javac
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
@danielribeiro
danielribeiro / scaffold.clj
Created March 16, 2012 20:11 — forked from ghoseb/scaffold.clj
Scaffold by Christophe Grand
(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))
@danielribeiro
danielribeiro / index.txt
Created April 9, 2012 04:06 — forked from gus/index.txt
Ruby/Clojure analogs
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:
@danielribeiro
danielribeiro / deftest*.clj
Created February 14, 2013 05:40 — forked from mybuddymichael/deftest*.clj
Simple spec helper for clojure tests
(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 #"-+" "-")
; 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)
@danielribeiro
danielribeiro / gist:5872520
Created June 26, 2013 22:59
a bundle gem file
export BUNDLE_GEMFILE=CapGemfile
@danielribeiro
danielribeiro / gist:6043289
Created July 20, 2013 00:30
simple class macro in wisp
(defmacro class [name]
`(set! ~name
(do (defn ~name []) ~name ))
)
(class A)
@danielribeiro
danielribeiro / us.html
Created October 1, 2013 06:22
soundcloud us
<!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>
@danielribeiro
danielribeiro / self_kill.sh
Last active December 25, 2015 01:29
self killing shell
#!/bin/bash
# trap "kill -- -$BASHPID" SIGINT SIGTERM EXIT
trap 'exit 42' SIGINT SIGQUIT SIGTERM
function sayit() {
while [[ 1 ]]
do echo oi
sleep 1
done
}
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);
}