Skip to content

Instantly share code, notes, and snippets.

View bcambel's full-sized avatar
🌴
On vacation

Bahadir Cambel bcambel

🌴
On vacation
View GitHub Profile
(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 #" ")
@bcambel
bcambel / csc.clj
Created January 7, 2015 15:35
Cascalog sample
(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)

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

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.

Vectors

<div class="navbar navbar-default">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="navbar-collapse collapse navbar-responsive-collapse">
@bcambel
bcambel / git_cheat.txt
Created December 18, 2014 14:20
Git Cheat sheet
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]
@bcambel
bcambel / cassandra.sh
Created December 17, 2014 22:42
Install Cassanda on ubuntu
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
@bcambel
bcambel / errors.clj
Last active August 29, 2015 14:11 — forked from adambard/errors.clj
(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 *@*.*"
@bcambel
bcambel / install.sh
Last active October 26, 2015 22:04 — forked from wdullaer/install.sh
# 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

@bcambel
bcambel / delete_keys.py
Created December 14, 2014 18:57
Delete REDIS keys by a given pattern
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*"