Skip to content

Instantly share code, notes, and snippets.

Sergey Yavnyi blacktaxi

Block or report user

Report or block blacktaxi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
blacktaxi / custom-clojure-map.clj
Created Jan 27, 2012 — forked from david-mcneil/custom-clojure-map.clj
Creating a custom Clojure map type
View custom-clojure-map.clj
(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 / oop.lua
Created Jul 6, 2012
Another basic OOP in lua with inheritance and virtual methods.
View oop.lua
-- creates a class table which has a "new" method to create object instances.
class = function (parentclass, classdef)
local cls = {
__classdef__ = classdef or {},
__parent__ = parentclass or {},
-- instance constructor
new = function(cls, ...)
local instance = {
super = cls.__parent__.__classdef__,
blacktaxi / polylens.ts
Last active Mar 28, 2018
polymorphic lens in TypeScript 2.8
View polylens.ts
* Gives you an object type compatible with given key type TKey.
* For example,
* type Example = ObjFor<'a'>
* is expanded to
* type Example = {
blacktaxi / ruby-fmt.clj
Created Jan 25, 2012
Ruby-like string interpolation in Clojure
View ruby-fmt.clj
; Ruby has an awesome feature -- string interpolation. Read about it on the internet.
; On the other hand, Clojure only has cumbersome Java string formatting, which can not be
; used without pain after you've tried Ruby.
; So here's this simple macro that basically allows you to do most things you could do
; with Ruby string interpolation in Clojure.
(ns eis.stuff
(:require [clojure.string]))
blacktaxi / redux-devtools.ts
Created Sep 1, 2017
Time travel debugging with Focal! (use Redux dev tools browser extension)
View redux-devtools.ts
import { Atom } from '@grammarly/focal'
import { createStore } from 'redux'
declare global {
interface Window {
__REDUX_DEVTOOLS_EXTENSION__?: () => undefined
blacktaxi /
Last active Jul 10, 2017
DnD die roll script
#!/usr/bin/env python
if __name__ == '__main__':
import sys, random, re
roll_re = r'(?P<rolls>\d+)d(?P<die>\d+)((?P<mod>(\+|-)\d+))?'
parsed = re.match(roll_re, sys.argv[1].strip()) if len(sys.argv) == 2 else None
if parsed is not None:
d = parsed.groupdict()
rolls, die, mod = int(d['rolls']), int(d['die']), (int(d['mod']) if d['mod'] is not None else 0)
blacktaxi /
Created Jul 9, 2017
Cleaning up duplicates in Dropbox's Camera Uploads
#!/usr/bin/env python
import sys, os, re
from PIL import Image, ImageChops
def find(root, pattern):
for root, dns, fns in os.walk(root):
for fn in fns:
if re.match(pattern, fn):
yield (root, fn)
blacktaxi / fsm.clj
Created Jan 27, 2012 — forked from Pet3ris/fsm.clj
Finite State Machine in Clojure core.logic
View fsm.clj
(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)
;; ^ |
blacktaxi / webkit-speech-recognition.js
Created Apr 17, 2017
webkitSpeechRecognition API usage example
View webkit-speech-recognition.js
// copy-paste this into a Chrome new tab console and allow mirophone input
// when prompted
var r = new webkitSpeechRecognition()
r.continuous = true
r.interimResults = true
r.onresult = e =>
blacktaxi / .gitconfig
Created Mar 23, 2017
git alias for tagging commits with Jira ticket IDs
View .gitconfig
# commit with Jira ticket ID tag in commit message.
# current branch name has to start with a valid Jira ticket ID, in upper case.
c = "!f() { \
if [[ -z $1 ]]; \
then \
echo "Error: No commit message provided."; \
exit 1; \
else \
local ticketId=$(git rev-parse --abbrev-ref HEAD | grep -Eo "^[A-Z]+-[0-9]+"); \
You can’t perform that action at this time.