Skip to content

Instantly share code, notes, and snippets.

View blacktaxi's full-sized avatar
🇺🇦
russia is a terrorist state, russians are a terrorist nation

Serhii Yavnyi blacktaxi

🇺🇦
russia is a terrorist state, russians are a terrorist nation
View GitHub Profile
@blacktaxi
blacktaxi / interpolate.clj
Created January 25, 2012 21:20 — forked from alandipert/interpolate.clj
interpolate.clj
;;; ENVIRONMENTAL IMPACT STATEMENT
;;;
;;; This program was written on recycled memory.
;;; No cons cells were created.
;;;
(ns interpolate
(:use [clojure.walk :only (postwalk)]))
(defmacro s
@blacktaxi
blacktaxi / main.clj
Created January 25, 2012 21:23 — forked from lynaghk/main.clj
Cassowary constraint solver in ClojureScript
;;Using the Cassowary constraint solver from ClojureScript
;;This demo shows using multimethods for readable constraint syntax using +, -, and =.
;;Output is a row of circles with random radii spaced so that the space between their boundaries is uniform.
(ns c2.main
;;refer-clojure :exclude is currently broken in ClojureScript master
;;Ticket open: http://dev.clojure.org/jira/browse/CLJS-114
;;Fix applied here: https://github.com/lynaghk/clojurescript/tree/114-refer-clojure-exclude
(:refer-clojure :exclude [+ - =])
@blacktaxi
blacktaxi / bells.clj
Created January 25, 2012 21:30 — forked from jennifersmith/bells.clj
Cheesy Holiday Music and bell synthesis example
(ns overtone-xmas.bells
( :use [overtone.live]
[overtone.sc.machinery.defcgen]))
;;http://computermusicresource.com/Simple.bell.tutorial.html
(def dull-partials
[
0.56
@blacktaxi
blacktaxi / haskjure.clj
Created January 26, 2012 13:49 — forked from djhworld/haskjure.clj
useful haskell functions that I can't seem to find in clojure
(defn group [xs]
"splits its sequence argument into a list of lists of equal, adjacent elements."
(partition-by identity xs))
(defn zip [xs ys]
"makes a list of vector tuples, each tuple containing elements of both sequences occuring at the same position"
(map vector xs ys))
(defn lines [str]
"For a given string, split it into a vector using a newline terminator as a delimiter"
@blacktaxi
blacktaxi / custom-clojure-map.clj
Created January 27, 2012 07:04 — forked from david-mcneil/custom-clojure-map.clj
Creating a custom Clojure map type
(ns people
(:use [clojure.string :only (join)]
[clojure.pprint :only (pprint simple-dispatch)]))
;; we can make maps using the special literal form:
{:a 100
:b 200}
(class {:a 100 :b 200})
@blacktaxi
blacktaxi / fsm.clj
Created January 27, 2012 07:07 — forked from Pet3ris/fsm.clj
Finite State Machine in Clojure core.logic
(ns fsm
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]))
;; Encoding a Finite State Machine and recognizing strings in its language in Clojure core.logic
;; We will encode the following FSM:
;;
;; (ok) --+---b---> (fail)
;; ^ |
(ns monad-explore.core
(:use clojure.algo.monads))
(defmacro let?
"Almost the same as let. If you add the :ensure keyword paired with
some predicate as a var in the let form, let? will not continue
unless the predicate evaluates to true. (The predicate will have
access to all bindings above.)"
[bindings & body]
(let [[bind [kwd pred & more]] (split-with (complement #{:ensure}) bindings)]
@blacktaxi
blacktaxi / tree.md
Created April 24, 2012 05:24 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@blacktaxi
blacktaxi / donotuse.py
Created April 28, 2012 21:32 — forked from e000/donotuse.py
How to ALWAYS use lambdas.
##########################################################
# How to properly use Python. An efficient and yet educa-#
# tonal guide to the proper use of the lambda constru- #
# ct in Python 2.x. [DO USE THIS AT ALL TIMES] #
# by: e000 (13/6/11) #
##########################################################
## Part 1. Basic LAMBDA Introduction ##
# Well, it's worth diving straight into what lambdas are.
# Lambdas are pretty much anonymous "one line" functions
$snapins = Get-PSSnapin -Registered
$snapins | Add-PSSnapin
Get-Module -ListAvailable | Import-Module
Get-PSSnapin | Format-Table -autosize PSVersion, Name
Get-Module | Format-Table -autosize ModuleType, Name
function ff ([string] $glob) { get-childitem -recurse -include $glob }