Skip to content

Instantly share code, notes, and snippets.

🌉
SF, hacking, thinking, observing, feeling

Anton Podviaznikov podviaznikov

🌉
SF, hacking, thinking, observing, feeling
Block or report user

Report or block podviaznikov

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
@podviaznikov
podviaznikov / clojure-logs-beanstalk.clj
Created May 15, 2013
to make clojure clojure.tools.logging work on amazon beanstalk past following code somewhere in the app. In case of ring/compojure project on top of handler.
View clojure-logs-beanstalk.clj
(alter-var-root
#'clojure.tools.logging/*logger-factory*
(constantly (clojure.tools.logging.impl/jul-factory)))
@podviaznikov
podviaznikov / clojure-require-https.clj
Created May 17, 2013
how to force https traffic in clojure web app
View clojure-require-https.clj
(defn https-url [request-url]
(str (str (str (str "https://" (:server-name request-url) ":") "443")) (:uri request-url)))
(defn require-https
[handler]
(fn [request]
(if (= (:scheme request) :http)
(ring.util.response/redirect (https-url request))
(handler request))))
@podviaznikov
podviaznikov / big-o-links
Last active Dec 17, 2015
Some links with Big O related information and algorithms articles in general
View big-o-links
@podviaznikov
podviaznikov / jobs-sites.md
Last active Dec 18, 2015
Sites that lists some good jobs.
@podviaznikov
podviaznikov / get-day-name.clj
Created Jun 11, 2013
Get day name from date represented as string in "YYYY-MM-DD" format.
View get-day-name.clj
(:require [clj-time.format :as clj-time-format]))
(defn get-day [date-str]
(let [date (clj-time-format/parse (clj-time-format/formatter "YYYY-MM-dd") date-str)
day (clj-time-format/unparse (clj-time-format/formatter "EEEE") date)]
day))
(get-day "2013-06-09")
"Monday"
@podviaznikov
podviaznikov / bubblesort.clj
Last active Dec 25, 2015
Bubble sort implementation in Clojure.
View bubblesort.clj
(defn bubble-step [coll was-changed less?]
(if (second coll)
(let [[x1 x2 & xs] coll
is-less-than (less? x1 x2)
smaller (if is-less-than x1 x2)
larger (if is-less-than x2 x1)
is-changed (or was-changed (not is-less-than))
[sorted is-sorted] (bubble-step (cons larger xs) is-changed less?)]
[(cons smaller sorted) is-sorted])
[coll (not was-changed)]))
View sum.btree.js
var sumBTree = function(tree){
if(!tree || tree.length == 0) return 0
return tree[0] + sumBtree(tree[1]) + sumBtree(tree[2])
}
var tree = [1, [2, [1], [6]], [3, [1]]]
sumBTree(tree) // 14
@podviaznikov
podviaznikov / insertionsort.go
Created Oct 21, 2013
Insertion sort implemented with Go
View insertionsort.go
func insertionSort(data []int) []int {
for n := 1; n < len(data); n++ {
v := data[n]
for k:=n - 1; k >= 0; k-- {
if v < data[k] {
// swap
data[k+1] = data[k]
data[k] = v
}
}
You can’t perform that action at this time.