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
(use 'clojure.java.io) | |
(let [pred (every-pred | |
#(.isDirectory %) | |
#(not (.startsWith (.getName %) ".")) | |
#(not (some (partial = (.getName %)) ["Exclude Name 0" "Exclude Name 1" "Exclude Name 2"]))) | |
dest "/Path/to/Destination" | |
src "/Path/to/Source" ] | |
(doseq [f (filter pred (-> src file .listFiles seq))] | |
(.renameTo f (file dest (.getName f))) )) |
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
(define (memoize f) | |
(define ht (make-hash)) | |
(define (f-mem . args) | |
(if (hash-has-key? ht args) | |
(hash-ref ht args) | |
(begin | |
(hash-set! ht args (apply f args)) | |
(hash-ref ht args)))) | |
f-mem) |
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
#!/bin/bash | |
export JAVA_OPTS="-Xmx2048m -XX:ReservedCodeCacheSize=256m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -XX:NewRatio=3 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSClassUnloadingEnabled -Dfile.encoding=UTF-8 -XX:+TieredCompilation -XX:TieredStopAtLevel=1" | |
export JRUBY_OPTS="--1.9 -J-noverify -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1" | |
torquebox run -b 0.0.0.0 |
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
Class Dog | |
has_many :tags | |
belongs_to :person | |
end | |
Class Person | |
has_many :dogs | |
end | |
d = Dog.new |
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
#Sample 1 | |
puts "#{$@.first}: #{$!.message} (#{$!.class})", $@.drop(1).map{|s| "\t#{s}"} | |
#Sample 2 | |
puts "#{e.backtrace.first}: #{e.message} (#{e.class})", e.backtrace.drop(1).map{|s| "\t#{s}"} |
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
true || true and false #=> false | |
true || true && false #=> true |
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
ary = ["A", "B", "C", "B", "A"] | |
ary.group_by { |e| e }.select { |k, v| v.size > 1 }.map(&:first) | |
ary.sort.chunk { |e| e }.select { |e, count| count.size > 1 }.map(&:first) | |
ary.select { |e| ary.count(e) > 1 }.uniq |
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
rails g migration add_public_and_private_to_document public:string private:string | |
bin/rails generate migration AddSomeRefAndSomeColumnToSomeTable some:references some_column:boolean |
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
obj = SomeObject.new | |
obj.define_singleton_method(:new_method) do | |
"do some things" | |
end | |
# Using a mixin | |
module AdditionalMethods | |
def new_method |
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
class Class | |
#firstly, the * decoration on the parameter variable | |
#indicates that the parameters should come in as an array | |
#of whatever was sent | |
def my_attr_accessor(*args) | |
#We simply iterate through each passed in argument... | |
args.each do |arg| | |
#Here's the getter |
OlderNewer