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 / update.py
Last active August 29, 2015 14:17
Compare the MD5 of 2 files
import socket
import subprocess
current = "/var/www/star-track/star-tracker.jar"
latest = "/opt/star-track/release/star-tracker.jar"
def get_md5(f):
proc = subprocess.Popen(["md5sum", f],stdout=subprocess.PIPE)
result_str = ""
md5 = ""
@bcambel
bcambel / start.cl
Created February 12, 2015 10:06
Paul Graham LISP
; The Lisp defined in McCarthy's 1960 paper, translated into CL.
; Assumes only quote, atom, eq, cons, car, cdr, cond.
; Bug reports to lispcode@paulgraham.com.
(defun null. (x)
(eq x '()))
(defun and. (x y)
(cond (x (cond (y 't) ('t '())))
('t '())))
@bcambel
bcambel / format.conf
Created February 2, 2015 07:02
nginx access log format
log_format info '$connection $msec $status $request_time $remote_addr $host '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
@bcambel
bcambel / cluster.py
Created January 26, 2015 13:08
Different Clustering algorithms
"""
=========================================================
Comparing different clustering algorithms on toy datasets
=========================================================
This example aims at showing characteristics of different
clustering algorithms on datasets that are "interesting"
but still in 2D. The last dataset is an example of a 'null'
situation for clustering: the data is homogeneous, and
there is no good clustering.
@bcambel
bcambel / destruct.clj
Created January 21, 2015 12:50
clojure destructuring tutorial
;; all the following destructuring forms can be used in any of the
;; Clojure's `let` derived bindings such as function's parameters,
;; `let`, `loop`, `binding`, `for`, `doseq`, etc.
;; list, vectors and sequences
[zero _ _ three & four-and-more :as numbers] (range)
;; zero = 0, three = 3, four-and-more = (4 5 6 7 ...),
;; numbers = (0 1 2 3 4 5 6 7 ...)
;; maps and sets
@bcambel
bcambel / fetch.clj
Created January 20, 2015 21:38
Fetch images
(ns fetcher.core
(:use [clojure.java.io :as io])
(:use [net.cgrand.enlive-html]))
(defn fetch-all-images-from-url [src-url dest-folder]
(let [
; get root from src-url: http://google.com/alias1/2/3 ---> http://google.com
root-url (clojure.string/join "/" (take 3 (clojure.string/split src-url #"/")))
; function: if image url starts with "/" ( / character is: \/ in Clojure, ex \a \b etc...) append root url
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer:
" Amir Salihefendic
" http://amix.dk - amix@amix.dk
"
" Version:
" 5.0 - 29/05/12 15:43:36
"
" Blog_post:
" http://amix.dk/blog/post/19691#The-ultimate-Vim-configuration-on-Github
set -x LEIN_SNAPSHOTS_IN_RELEASE y
set -x DOCKER_HOST tcp://192.168.59.103:2376
set -x DOCKER_CERT_PATH /Users/bahadir/.boot2docker/certs/boot2docker-vm
set -x DOCKER_TLS_VERIFY 1
set -x LC_ALL en_US.UTF-8
set -x LANG en_US.UTF-8
alias tigs "tig status"
alias gitpatch "git add * -p"
alias gitpm "git push origin master"
@bcambel
bcambel / hadoop.sh
Created January 10, 2015 06:23
Set up Hadoop 2.6 in Ubuntu. Based on http://codesfusion.blogspot.nl/2013/10/setup-hadoop-2x-220-on-ubuntu.html updated to 2.6
sudo apt-get install openjdk-7-jdk
java -version
# java version "1.7.0_25"
# OpenJDK Runtime Environment (IcedTea 2.3.12) (7u25-2.3.12-4ubuntu3)
# OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
cd /usr/lib/jvm
ln -s java-7-openjdk-amd64 jdk
sudo apt-get install openssh-server
(ns rbl.feature-extraction.user-agent
(:use [clojure.core.memoize :only [memo]])
(:require [clojure.tools.logging :as log])
(:import [nl.bitwalker.useragentutils UserAgent DeviceType Browser OperatingSystem]))
(defn str->features [string]
(try
(let [user-agent (UserAgent. (or string ""))]
{:browser_group (-> user-agent .getBrowser .getGroup .getName)
:os_group (-> user-agent .getOperatingSystem .getGroup .getName)