Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
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 aud_cas.print_fields | |
| (:use cascalog.api) | |
| (:require [clojure.string :as str]) | |
| ) | |
| (defn parse_input_record | |
| "Parse the text of the input record into fields in a map" | |
| [input_record] | |
| (let [prefix_string (get (str/split input_record #"\: ") 0) | |
| prefix_pairs (str/split prefix_string #" ") |
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 cascalog.conj.tunisia | |
| (:use [cascalog api playground]) | |
| (:use [cascalog.contrib.incanter]) | |
| (:use [cascalog.util :only [collectify]]) | |
| (:use [clojure.contrib.def :only [defnk]]) | |
| (:require [cascalog [ops :as c] [vars :as v]]) | |
| (:require [clojure.data [json :as json]])) | |
| (bootstrap-emacs) |
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
| Setup | |
| ----- | |
| git clone <repo> | |
| clone the repository specified by <repo>; this is similar to "checkout" in | |
| some other version control systems such as Subversion and CVS | |
| Add colors to your ~/.gitconfig file: | |
| [color] |
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
| sudo apt-get install openjdk-7-jre -y | |
| echo "deb http://debian.datastax.com/community stable main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list | |
| curl -L http://debian.datastax.com/debian/repo_key | sudo apt-key add - | |
| sudo apt-get install dsc21 -y --force-yes | |
| sudo service cassandra status |
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 example.errors) | |
| (defn clean-address [params] | |
| "Ensure (params :address) is present" | |
| (if (empty? (params :address)) | |
| [nil "Please enter your address"] | |
| [params nil])) | |
| (defn clean-email [params] | |
| "Ensure (params :email) matches *@*.*" |
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
| # Add Docker PPA and install latest version | |
| sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 | |
| sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" | |
| sudo apt-get update | |
| sudo apt-get install lxc-docker -y | |
| # Install fig | |
| sudo sh -c "curl -L https://github.com/docker/fig/releases/download/1.0.0/fig-`uname -s`-`uname -m` > /usr/local/bin/fig" | |
| sudo chmod +x /usr/local/bin/fig |
-
user signs up with email and password:
- if the email exists, validation error.
- if the email is linked to a facebook account, they'll see the "merge?" box when they try to link later
- if the email doesn't exist, create the account!
- Username is auto-generated
- we send a welcome! email
- we send a verification email
-
user decides to link a Facebook account:
-
when the user clicks on the "Link Facebook" link in profile, login with javascript SDK
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
| import redis | |
| import sys | |
| r = redis.StrictRedis('localhost',6379) | |
| def delete(pattern='a*'): | |
| print [r.delete(k) for k in r.keys(pattern)] | |
| if __name__ == "__main__": | |
| pattern = sys.argv[1] if len(sys.argv)>1 else "a*" |