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.walk) | |
(let [h (fn [f] | |
(let [r (cond | |
(vector? f) | |
`(~(first f) ~@(rest f)) | |
(map? f) | |
(map (fn [[k v]] | |
`(field ~k ~(h v))) | |
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
$ bundle exec rake db:migrate | |
(in providence) | |
DEPRECATION WARNING: Rake tasks in vendor/plugins/common/tasks and vendor/plugins/rails_rcov/tasks are deprecated. Use lib/tasks instead. (called from providence/rake/ruby/1.8/gems/rails-2.3.8/lib/tasks/rails.rb:10) | |
New RightAws::S3Interface using single-threaded mode | |
== AddPartnerBrandCodeToPartnerHotels: migrating ============================= | |
-- add_column(:partner_hotels, :partner_brand_code, :string) | |
rake aborted! | |
An error has occurred, all later migrations canceled: | |
Mysql::Error: Duplicate column name 'partner_brand_code': ALTER TABLE `partner_hotels` ADD `partner_brand_code` varchar(255) |
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
[branch "solrland"] | |
remote = origin | |
merge = refs/heads/solrland |
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 remove-out-of-range-rates [rates min-rate max-rate] | |
(let [out-of-range? #(not (<= min-rate (:total_rate %) max-rate)) | |
reducer (fn [m {:keys [rates] :as item}] | |
(let [frates (remove out-of-range? rates)] | |
(if-not (empty? frates) | |
(conj m (assoc item :rates frates)) | |
m)))] | |
(reduce reducer [] rates))) | |
(remove-out-of-range-rates [{:rates [{:total_rate 10} {:total_rate 15}]} |
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
Exception in thread "I/O dispatcher 3" java.lang.AssertionError: Assert failed: (seq? rates) | |
at sstj.core$process_results.doInvoke(core.clj:66) | |
at clojure.lang.RestFn.invoke(RestFn.java:1178) | |
at sstj.marriott$make_on_success_cb$fn__10057.invoke(marriott.clj:362) | |
at com.twinql.clojure.async-client.HttpCallback.completed(async_client.clj:77) | |
at org.apache.http.nio.concurrent.BasicFuture.completed(BasicFuture.java:101) | |
at org.apache.http.impl.nio.client.DefaultResultCallback.completed(DefaultResultCallback.java:47) | |
at org.apache.http.impl.nio.client.DefaultAsyncRequestDirector.responseCompleted(DefaultAsyncRequestDirector.java:391) | |
at org.apache.http.impl.nio.client.NHttpClientProtocolHandler.processResponse(NHttpClientProtocolHandler.java:357) | |
at org.apache.http.impl.nio.client.NHttpClientProtocolHandler.inputReady(NHttpClientProtocolHandler.java:196) |
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
mysql> show variables where variable_name like 'character_set%'; | |
+--------------------------+-------------------------------------------+ | |
| Variable_name | Value | | |
+--------------------------+-------------------------------------------+ | |
| character_set_client | latin1 | | |
| character_set_connection | latin1 | | |
| character_set_database | latin1 | | |
| character_set_filesystem | binary | | |
| character_set_results | latin1 | | |
| character_set_server | utf8 | |
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
(let [x 10 | |
m {:id 1} | |
m (if (= (:id m) 1) (merge m {:id 2}) m) | |
m (if (< x 10) (merge m {:y true}) m) | |
m)) |
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 counter [] | |
(let [x (atom 0)] | |
(fn [] (swap! x #(+ % 1)) @x))) | |
(let [c (counter)] | |
(prn (c)) | |
(prn (c)) | |
(prn (c))) |
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 p [path & {{:as params} :params | |
{:as headers :or {}} :headers}] | |
[params headers]) | |
;; was hoping to see :headers {} here | |
(p "path" :params {:id 1}) |
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 PageCategory < ActiveRecord::Base | |
belongs_to :page | |
belongs_to :category | |
validates_presence_of :page_id | |
validates_presence_of :category_id | |
end | |
class Category < ActiveRecord::Base | |
has_many :page_categories, :dependent => :destroy | |
has_many :pages, :through => :page_categories |