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
$template TestFormat,"Message: %msg%\n"
$template TestFile,"/tmp/test_%$year%%$month%%$day%%$hour%.log"
# Writes matching messages to path defined by TestFile template in TestFormat format
:syslogtag, contains, "test" -?TestFile;TestFormat
# Drops messages matching this syslog tag
:syslogtag, contains, "test" ~
@bcambel
bcambel / goodies.bash
Created February 11, 2014 13:26
Unix goodies
# get the largest 10 under current directory
du -hsx * | sort -rh | head -10
@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
@bcambel
bcambel / episodes.html
Created February 25, 2014 22:10
Episodes based on
<!doctype html>
<html>
<head>
<title>Episodes Example 1</title>
<meta charset="UTF-8">
<script>
var EPISODES = EPISODES || {};
EPISODES.q = []; // command queue
EPISODES.mark = function(mn, mt) { EPISODES.q.push( ["mark", mn, mt || new Date().getTime()] ); };
#! /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)))))
@bcambel
bcambel / fib.clj
Last active August 29, 2015 14:01
Hint in clojure
(defn fib2 [n]
(if (<= n 1)
1
(+ (fib2 (dec n)) (fib2 (- n 2)))))
(defn ^:static fib ^long [^long n]
(if (<= n 1)
1
(+ (fib (dec n)) (fib (- n 2)))))
@bcambel
bcambel / big_data.html
Created May 22, 2014 09:52
Big data list
<div class="entry-content">
<p>“<em><strong>Big-data</strong></em>” is one of the most inflated buzzword of the last years. Technologies born to handle huge datasets and overcome limits of previous products are gaining popularity outside the research environment. The following list would be a reference of this world. It’s still incomplete and always will be.</p>
<p><strong>Framework</strong></p>
<ul>
<li><a href="http://hadoop.apache.org/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://hadoop.apache.org']);"><strong>Apache Hadoop</strong></a>: framework for distributed processing. Integrates&nbsp;MapReduce (parallel processing), YARN (job scheduling) and HDFS (distributed file system)</li>
</ul>
<p><strong>Distributed Programming</strong></p>
<ul>
<li><a href="http://databricks.github.io/simr/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://databricks.github.io']);"><strong>AMPLab SIMR</strong></a>: run Spark on Hadoop MapReduce v1</li>
<li><a href="http://inc
(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