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
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 'json' | |
require 'set' | |
class ProfileConverter | |
def initialize(profile, io=$stdout, time_threshold=0.01) | |
@profile = profile | |
@io = io | |
@time_threshold = time_threshold | |
end |
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 pomodoro { | |
case $1 in | |
start ) | |
echo 'terminal-notifier -title "🍅 Pomodoro Done" -message "Starting short break…"' | at + 25 minutes &> /dev/null | |
;; | |
break ) | |
echo 'terminal-notifier -title "⌛ Short Break Done" -message "Start your next Pomodoro."' | at + 5 minutes &> /dev/null | |
;; | |
esac |
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::property = (prop, desc) -> | |
Object.defineProperty @prototype, prop, desc | |
class Person | |
constructor: (@firstName, @lastName) -> | |
@property 'fullName', | |
get: -> "#{@firstName} #{@lastName}" | |
set: (name) -> [@firstName, @lastName] = name.split ' ' | |
p = new Person 'Leroy', 'Jenkins' |
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
#!/usr/bin/env ruby | |
require 'open3' | |
# Returns true if all files are EOF | |
# | |
def all_eof(files) | |
files.find { |f| !f.eof }.nil? | |
end |
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
# Do *not* load any libs here that are *not* part of Ruby’s standard-lib. Ever. | |
desc "Install all dependencies" | |
task :bootstrap do | |
if system('which bundle') | |
sh "bundle install" | |
sh "git submodule update --init" | |
# etc | |
else | |
$stderr.puts "\033[0;31m[!] Please install the bundler gem manually: $ [sudo] gem install bundler\e[0m" |
OlderNewer