Skip to content

Instantly share code, notes, and snippets.

View zahardzhan's full-sized avatar

Роман Захаров zahardzhan

View GitHub Profile
@zahardzhan
zahardzhan / gist:a68ce2d139f9f95b0456
Created January 24, 2015 06:55
Dota 2 Voice & Open Micro Toggle
// Put in Program Files (x86)/Steam/steamapps/common/dota 2 beta/dota/cfg/autoexec.cfg
alias vo/+ "voice_enable 1; vo/om-~"
alias vo/- "voice_enable 0"
alias vo/om~ "vo/om+~"
alias vo/om+ "voice_vox 1"
alias vo/om- "voice_vox 0"
alias vo/om+~ "vo/om+; alias vo/om~ vo/om-~"
alias vo/om-~ "vo/om-; alias vo/om~ vo/om+~"
bind kp_multiply vo/om~
bind kp_minus vo/-
@zahardzhan
zahardzhan / Send More Money.md
Last active August 29, 2015 14:23
Занятная задачка с хабра иллюстрирующая монады списка.

Паззл Send More Money

Занятная задачка с хабра иллюстрирующая монады списка.

Оригинал http://habrahabr.ru/company/infopulse/blog/260809

Ну и вот вам задачка, которая может попасться на собеседовании. Она не совсем тривиальна, возможно несколько подходов к решению и лучший из них не сразу очевиден — как-раз то, над чем стоит подумать. Вам предлагается следующий пазл:

@zahardzhan
zahardzhan / autoexec.cfg
Created August 1, 2015 13:24
Easy sound modes switch & tactical mode.
con_enable 1
con_filter_enable 1
con_filter_text [
con_notifytime 1.7
developer 1
alias +smpm+vr "+sixense_map_ping_mode; +voicerecord"
alias +smpm-vr "+sixense_map_ping_mode; -voicerecord"
alias -smpm-vr "-sixense_map_ping_mode; -voicerecord"
alias +tacticalmode +smpm+vr
alias -tacticalmode -smpm-vr
@zahardzhan
zahardzhan / geolinks.snowflake.clj
Created August 21, 2015 14:26
snowflake uid generator
(defun str (&rest args)
"Returns the concatenation of string values of the args.
With no or nil args, returns the empty string."
(with-output-to-string (s)
(dolist (arg args) (princ (or arg "") s))))
(defmacro with-gensyms ((&rest names) &body body)
`(let ,(loop for n in names collect `(,n (gensym)))
,@body))
@zahardzhan
zahardzhan / *scratch*.clj
Created January 29, 2010 12:29
part of leica
(defn set-root-logger-log-level! [log-level]
(let [root-logger (Logger/getLogger "")
console-handler (first (.getHandlers root-logger))
date-formatter (java.text.SimpleDateFormat. "HH:mm:ss")
log-formatter (proxy [Formatter] []
(format
[#^LogRecord record]
(str \return
(.format date-formatter (Date. (.getMillis record)))
\space (.getMessage record) \newline)))]
(defn fn-or
"Объединение функций возвращает функцию эквивалентную
(fn [x] (or (f x) (g x) ... ) или
(fn [x & xs] (or (f x1 x2 ...) (g x1 x2 ...) ... )"
[f & fs]
(if-not fs f (let [chain (apply fn-or fs)]
(fn ([x] (or (f x) (chain x)))
([x & xs] (or (apply f x xs) (apply chain x xs)))))))
(defn seq-dispatch
(defn up [] (int (Math/pow -1 (inc (.nextInt (new java.util.Random) 2)))))
(first (filter (partial = 10) (iterate #(+ % (up)) 0)))
(let [position (atom 0)
movements (cycle [-1 1 1])]
(defn up1 []
(reset! position (inc @position))
(nth movements @position)))
(use 'clojure.test)
(defn same
"Returns true if (f x) returns same value for any x in coll."
[f coll]
(apply = (map f coll)))
(deftest same-test
(is (same :x [{:x nil} {:y nil}]))
(is (same :x [{:x 1} {:x 1 :y 2}]))
@zahardzhan
zahardzhan / fn.clj
Created February 20, 2010 10:45
fn namespace
(ns fn (:refer-clojure :exclude [not and or]))
(def not complement)
(defn and "Functions intersection."
([f] f)
([f & fs] (let [chain (apply and fs)]
(fn [& xs] (clojure.core/and (apply f xs)
(apply chain xs))))))