Skip to content

Instantly share code, notes, and snippets.

View erasmas's full-sized avatar
🇺🇦

Dmytro Kobza erasmas

🇺🇦
View GitHub Profile
@erasmas
erasmas / gist:2627847
Created May 7, 2012 13:44
wifi authenticator
(ns epam-auth.core
(:import (com.gargoylesoftware.htmlunit WebClient))
(:gen-class :main true)))
(def client (doto (WebClient.)
(.setUseInsecureSSL true)
(.setJavaScriptEnabled true)))
(defn login-form []
(let [page (.getPage client "http://duckduckgo.com")
@erasmas
erasmas / gist:6196488
Last active December 20, 2015 21:19
Handy script to download videos from www.infoq.com
#!/bin/bash
get-infoq-video () {
echo 'usage get-infoq-video http://www.infoq.com/presentations/Concurrency-Clojure'
curl -A "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10')" $1 | grep "<source src=" |sed -E 's/.*<source src="([^"]+)".*/\1/g' |xargs curl -O
}
(use 'clojure.java.io)
(defn read-lines [file]
(with-open [rdr (reader file)]
(doall (line-seq rdr))))
(defn dna-reverse-complement [dna]
"Takes a DNA string and returns it's reverse complement"
(apply str (map (fn [x]
(cond
(= "Test Testerson, 123 Test Lane, Testerville, TX"
(let [[a b] ["Test" "Testerson"]
{:keys [street-address city state]} test-address]
(str a " " b ", " street-address ", " city ", " state)))
@erasmas
erasmas / gist:8385212
Last active January 3, 2016 00:49
Drop every nth item from sequence
(fn [s n]
(keep-indexed
(fn [i v] (when (pos? (mod (inc i) n)) v))
s))
@erasmas
erasmas / gist:8389734
Created January 12, 2014 20:07
Greatest common divisor in Clojure
(defn gcd [a b]
(let [min (min a b)
max (max a b)
rem (mod max min)]
(if (zero? rem)
min
(recur min rem))))
(defn gcd2 [a b]
(let [quotient (/ a b)]
(defn compare-jobs
[m1 m2 key]
(loop [keys (clojure.set/intersection (set (keys m1)) (set (keys m2)))
changed-jobs {}]
(if (empty? keys)
changed-jobs
(let [name (first keys)
status (get-in m1 [name key])
updated-status (get-in m2 [name key])]
(if (= status updated-status)

1. Writool - tool for writers

Online markdown text editor capable to generate PDF and HTML. Contains a set of useful options for writers:

  • spelling correction
  • grammar checker
  • translations
  • synonyms

2. StoryTeller

Keybase proof

I hereby claim:

  • I am erasmas on github.
  • I am dmorozov (https://keybase.io/dmorozov) on keybase.
  • I have a public key whose fingerprint is 6618 55DB F07F 1E3D A04B 3114 ED24 AA27 0634 E2A0

To claim this, I am signing this object:

@erasmas
erasmas / gist:0d946ca76a17fb309bee
Last active August 29, 2015 14:07
Matrix trace using map-indexed from clatrix library.
(require '[clatrix.core :as cl])
(import '[clatrix.core Matrix])
(defn matrix-trace
[^Matrix m]
(->> m
(cl/map-indexed (fn [i j v] (if (= i j) v 0)))
(mapv #(reduce + %))
(reduce +)))