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
@bcambel
bcambel / gist:9000181
Last active August 29, 2015 13:56 — forked from mikeyk/gist:1329319
Redis vs Redis vs Memcached
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@bcambel
bcambel / gist:9168945
Created February 23, 2014 09:00 — forked from aphyr/gist:3200862
(ns messagepassing.core)
(import [java.util.concurrent LinkedTransferQueue])
(def m 10000000)
(defn queue-test []
(defn bounce [in out m]
(let [value (.take in)]
(if (< value m)
(do
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
(defn chunked-string-seq
([^java.io.Reader rdr]
(chunked-string-seq rdr :chunk-size 16))
([^java.io.Reader rdr &{chunk-size :chunk-size}]
{:pre [(some-> chunk-size pos?)]}
(let [buf (char-array chunk-size)]
(letfn [(f []
(when (pos? (.read rdr buf))
(cons (String. buf) (lazy-seq (f)))))]
(f)))))
(ns wikiparse.core
(:require [clojure.java.io :as io]
[clojure.data.xml :as xml]
[clojure.zip :refer [xml-zip]]
[clojure.data.zip.xml :refer [xml-> xml1-> text]])
(:import [ org.apache.commons.compress.compressors.bzip2 BZip2CompressorInputStream])
(:gen-class :main true))
(defn bz2-reader
"Returns a streaming Reader for the given compressed BZip2
(ns queries.postgres
(:gen-class)
(:require [cascalog.ops :as c])
(:use [cascalog.api])
(:import [com.twitter.maple.jdbc JDBCTap JDBCScheme TableDesc]
[cascading.tap.SinkMode]))
(defn db-tap [table]
(let [tap (com.twitter.maple.jdbc.JDBCTap.
"jdbc:postgresql://my-db-uri?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google

Hey! I saw this has been indexed by the search engines. It is a first draft of a post I ended up publishing on my blog at: Scaling PostgreSQL With Pgpool and PgBouncer

Thanks for stopping by!

PostgreSQL and Pgpool Architecture

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

Clojure does Objects Better

A hopefully short and concise explanation as to how Clojure deals with Objects. If you already write Clojure, this isn't for you.

You know what an Interface is if you write/read Java or PHP 5+. In Clojure it might be called defprotocol.

user> (defprotocol IABC
        (also-oo [this])
        (another-fn [this x]))

IABC