Skip to content

Instantly share code, notes, and snippets.

View tzach's full-sized avatar

Tzach Livyatan tzach

View GitHub Profile
@tzach
tzach / gist:3506717
Created August 29, 2012 04:07
Clojure Dojo Tuesday, August 28, 2012
(ns dojo.core
(use clojure.string))
(def *input*
" _ _ _ _ _ _ _
| _| _||_||_ |_ ||_||_|
||_ _| | _||_| ||_| _|")
(def *zeros*
" _ _ _ _ _ _ _ _ _
@tzach
tzach / gist:3697720
Created September 11, 2012 11:29
Solution to KataBankOCR in Clojure
;; Almost a full solution to KataBankOCR
;; taken from http://codingdojo.org/cgi-bin/wiki.pl?KataBankOCR
(ns dojo.core
(:require
[clojure.string :as str]
[clojure.set :as set]))
;; User Story 1
(def *dic*
@tzach
tzach / gist:4131498
Created November 22, 2012 14:40
Two solution to the Coin Change Kata in Clojure
(ns coins.core)
;;; Solution I
;;; recursive, with coin hash as a parameter
(defn make-coins-rec [coins amount h] ;; all possible solutions in a nested list
"return all valid solutions"
(cond
(zero? amount) h
(pos? amount) (map #(make-coins-rec coins (- amount %) (update-in h [%] inc)) coins)))
@tzach
tzach / gist:4140002
Created November 24, 2012 15:00
hello
(ns hello.core)
(defn foo
"I don't do a whole lot."
[x]
(println x "Hello, World!"))
(defn -main []
(foo "Yes, "))
@tzach
tzach / gist:4239925
Created December 8, 2012 11:37
first-enlive input
<!DOCTYPE html>
<html>
<head>
<title>tab title</title>
</head>
<body>
<h2 class="header">header</h2>
<div class="container">
@tzach
tzach / gist:4239938
Created December 8, 2012 11:39
first-enlive output
<!DOCTYPE html>
<html>
<head>
<title>Clojure example!</title>
</head>
<body>
<h2 class="header"> Shouts </h2>
<div class="container">
@tzach
tzach / live.clj
Last active February 7, 2017 02:20
example of ring, compojure and hiccup
(use 'ring.util.response
'ring.adapter.jetty)
;;;;; handler
(defn hello-handler [req]
(->
(response "Hello")
(content-type "text/html")))
@tzach
tzach / trace-transducer.clj
Created September 24, 2014 10:35
play around with a trivial trace transducer
;; play around with a trivial trace transducer
;; base on https://gist.github.com/ptaoussanis/e537bd8ffdc943bbbce7#file-transducers-clj
(defn trace-tran
"print the new input on any iteration.
Combine with other transducers for tracing"
[reducing-fn]
(fn new-reducing-fn
([] (reducing-fn))
([accumulation] (reducing-fn accumulation))
@tzach
tzach / kairosdb-stress.yaml
Last active September 22, 2020 13:18
cassandra-stress for KairosDB
### DML ###
# Keyspace Name
keyspace: kairos
# The CQL for creating a keyspace (optional if it already exists)
keyspace_definition: |
CREATE KEYSPACE kairos WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2};
# Table name
@tzach
tzach / backup-repos.py
Created July 7, 2015 07:05
Backup user repos from github, including wiki
#!/usr/bin/env python
# prerequisites
# sudo pip install pyopenssl ndg-httpsclient pyasn1 gitpython --upgrade
#
# Usage: ./backup-repos.py user
#
import requests