This file contains hidden or 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
(defmacro env-is | |
[ & env-with-action] | |
`(some #(if (= (first %) "test") (second %) false) | |
(partition 2 ~env-with-action))) | |
(println (env-is | |
"test" #(+ 1 2) | |
"prod" run-production)) |
This file contains hidden or 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
(ns mytwitter.core | |
(:require [clojure.browser.event :as event] | |
[clojure.browser.dom :as dom])) | |
(def button (dom/get-element "button")) | |
(def profile (dom/get-element "profile")) | |
(def tweets (dom/get-element "tweets")) | |
(defn alert [mess] | |
(.alert js/window mess)) |
This file contains hidden or 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
# create a 2D array representing the result set | |
def result_as_array(res) #:nodoc: | |
# | |
# check if we have any binary column and if they need escaping | |
ftypes = Array.new(res.nfields) do |i| | |
[i, res.ftype(i), res.fname(i)] | |
end | |
rows = res.values | |
typehash = ftypes.group_by { |_, type| type } |
This file contains hidden or 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
recursive grep: | |
find . -name "*.*" | xargs grep "SEARCH FOR THIS" |
This file contains hidden or 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
# See Mike Perham's proposal on ticket: https://rails.lighthouseapp.com/projects/8994/tickets/6477-activemodel-transformations | |
# Chainable Transformations API | |
require "active_support/core_ext/string/inflections" | |
require "active_support/concern" | |
module ActiveModel | |
module Transformers |
NewerOlder