Skip to content

Instantly share code, notes, and snippets.

View danielribeiro's full-sized avatar

Daniel Ribeiro danielribeiro

View GitHub Profile
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 / gist:66d5270e4bbc18454f62
Created February 23, 2015 22:54
default ruby shell
#!/usr/bin/env -i bash
/usr/bin/ruby -W0 ~/rubyscriptpath.rb
/===-_---~~~~~~~~~------____
|===-~___ _,-'
-==\\ `//~\\ ~~~~`---.___.-~~
______-==| | | \\ _-~`
__--~~~ ,-/-==\\ | | `\ ,'
_-~ /' | \\ / / \ /
.' / | \\ /' / \ /'
/ ____ / | \`\.__/-~~ ~ \ _ _/' / \/'
/-'~ ~~~~~---__ | ~-/~ ( ) /' _--~`
\_| / _) ; ), __--~~
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
@danielribeiro
danielribeiro / time-of-process.sh
Created April 23, 2015 20:13
time of a process
#source: http://unix.stackexchange.com/questions/7870/how-to-check-how-long-a-process-has-been-running
ps -p 88966 -o etime=
@danielribeiro
danielribeiro / binary_echo
Created April 23, 2015 20:14
echo binary data in unix
echo -n -e "\x00\x01\x02" > o
hexdump -C
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'
### Keybase proof
I hereby claim:
* I am danielribeiro on github.
* I am danielrb (https://keybase.io/danielrb) on keybase.
* I have a public key whose fingerprint is C9B0 988E 78CC C29E 4EDC 727B 21E9 F012 A2F0 26D1
To claim this, I am signing this object:
@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