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 #"-+" "-")
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:
require 'json'
require 'set'
class ProfileConverter
def initialize(profile, io=$stdout, time_threshold=0.01)
@profile = profile
@io = io
@time_threshold = time_threshold
end
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
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'
@danielribeiro
danielribeiro / popen3_test
Last active August 27, 2015 06:50 — forked from chrisn/popen3_test
Ruby example of using Open3.popen3 with a select loop to read a child process's standard output and standard error streams.
#!/usr/bin/env ruby
require 'open3'
# Returns true if all files are EOF
#
def all_eof(files)
files.find { |f| !f.eof }.nil?
end
@danielribeiro
danielribeiro / Rakefile
Last active August 27, 2015 08:15 — forked from alloy/Rakefile
A Rakefile that standardises program env installation and guides the user, as opposed to crashing with Ruby exceptions such as `LoadError`. The only case where this will *never* work reliably is if you use the `rubygems-bundler` (NOEXEC) plugin, which introduces chicken-and-egg problems.
# 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"