Skip to content

Instantly share code, notes, and snippets.

View pcomans's full-sized avatar
🙈

Philipp Comans pcomans

🙈
  • Software Engineer at @1debit
  • Sacramento
View GitHub Profile
(defn frac-pp [x]
(let [rat (if (rational? x) x (rationalize x))
num (numerator rat)
den (denominator rat)]
(println num)
(println "-----")
(println den)))
(frac-pp 1.5)
(frac-pp (/ 3 2))
(defn mkframe []
(let [frame (java.awt.Frame.)]
(.setVisible frame true)
(.setSize frame (java.awt.Dimension. 512 512))
(let [gfx (.getGraphics frame)]
(.drawString gfx (.. (java.util.Date.) toString) 160 256))))
(defn xors
"Returns bitwise XORs"
[max-x max-y]
(for [x (range max-x)
y (range max-y)]
[x y (bit-xor x y)]))
(def frame (java.awt.Frame.))
(.setVisible frame true)
(.setSize frame (java.awt.Dimension. 512 512))
(throw (Exception. "Oh noes!"))
(defn throw-catch [f]
(try
(f)
(catch ArithmeticException e "Are you bad at math?")
(catch Exception e (str "That didn't work!" e))
(finally (println "returning..."))))
(defn throw-catch [f]
[(try
(f)
(catch ArithmeticException e "No dividing by zero!")
(catch Exception e (str "You are so bad " (.getMessage e)))
(finally (println "returning... ")))])
#!/Users/philipp/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'annotate-gff' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
#!/usr/bin/bash
params=$*
ruby_version=$(ruby -v)
echo $ruby_version
dir=$(dirname $0)
if [[ $ruby_version == jruby* ]];
then
ruby "-J-Xmx2g" "${dir}/lib/annotate-gff.rb" ${params}
else
JRUBY!
warning: -J-Xmx2g argument ignored (launched in same VM?)
Hello
Still there?
if RUBY_PLATFORM =~ /java/
puts "JRUBY!"
command = "ruby -J-Xmx2g " + File.join(File.dirname(__FILE__), '..', 'lib/hello.rb')
system(command)
else
puts "MRI"
command = "ruby " + File.join(File.dirname(__FILE__), '..', 'lib/hello.rb')
system(command)
end
#!/usr/bin/bash
echo $*
RUBY_VERSION=/usr/bin/env ruby -v
echo $RUBY_VERSION
if [[ $RUBY_VERSION == "jruby*" ]];
then
echo "JRUBY\!"
else