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
## Preliminaries | |
apt-get install git curl | |
## Java | |
echo "Installing JDKs" | |
add-apt-repository ppa:webupd8team/java -y | |
apt-get update -qq | |
apt-get install oracle-java7-installer |
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
(ns lcmap-data-clj.logger | |
(:require [clojure.logging.impl :as log-impl]) | |
(:import [ch.qos.logback.classic Level])) | |
(comment "Usage example" | |
(set-level! 'lcmap-data-clj :debug) | |
(set-level! '[org.apache org.gdal] :info) | |
(set-level! '[com.datastax.driver co.paralleluniverse] :error)) |
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 'em-imap' | |
require 'logger' | |
require 'yaml' | |
# | |
# Watch IMAP mailboxes for messages and react however you like. | |
# | |
# Usage Example: | |
# | |
# Mailbag.run do |message| |
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 fizzer [n] | |
(if (= 0 (mod n 3)) "Fizz")) | |
(defn buzzer [n] | |
(if (= 0 (mod n 5)) "Buzz")) | |
(defn fizzerbuzzer [num] | |
(let [res [(fizzer num) (buzzer num)]] | |
(if (every? nil? res) num (apply str res)))) |
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
/** | |
* Usage: | |
* | |
* <script src="augmenter.js" type="text/javascript"></script> | |
* <script> | |
* new Augmenter({ attr: 'data-employee', url: '/employee?id=' }) | |
* </script> | |
* | |
* Any elements like this in your document: | |
* |
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 'faye/websocket' | |
# Configuration: | |
# | |
# With rackup | |
# map '/notifier' do | |
# run Notifier.new | |
# end | |
# | |
# With Rails, add this to config/routes.rb |
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
(defrecord Accept [media-range quality accept-extension]) | |
(defn accept [str] | |
"Parse a single accept string into a map" | |
; according to RFC2616, the "q" parameter must precede the accept-extension | |
(let [pattern #"([^;]+)\s*(?:;q=([0-9+\.]+))?\s*(;.+)*" | |
matches (re-find pattern str) | |
[_ media-range qvalue accept-extension] matches | |
quality (java.lang.Double/parseDouble (or qvalue "1"))] | |
(Accept. media-range quality accept-extension))) |
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
# PassiveRecord disables all of the mutable behaviors of a class that behaves like an ActiveRecord::Base | |
module PassiveRecord | |
module Base | |
extend ActiveSupport::Concern | |
module InstanceMethods | |
def passive_record_benign_method(*args, &block) | |
return false | |
end | |
end |
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
$ du -sh .git | |
260K .git |
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
# Bulk API design | |
# | |
# resources :posts | |
class PostsController < ApplicationController | |
before_filter :separate_bulk_ids | |
# GET /posts/1 | |
# params[:id] => 1 | |
# params[:ids] => [ 1 ] |