Skip to content

Instantly share code, notes, and snippets.

😁
Surprised about this status thing

Alexander Solovyov piranha

😁
Surprised about this status thing
Block or report user

Report or block piranha

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
@piranha
piranha / async-profiler-mw.clj
Created Feb 5, 2019
Async Profile Middleware
View async-profiler-mw.clj
(defn make-profile-transform [^String thread-name]
(fn [^String s]
(when (> (.indexOf s thread-name) -1)
(-> s
(str/replace #"com.fasterxml.jackson.+" "JACKSON...")
(str/replace #"org.elasticsearch.client.RestClient.+" "ES request...")
(str/replace #"clojure.tools.logging/.+" "LOG...")))))
(defn profiler-mw [handler]
View cx.clj
(defmacro cx [& classes]
"This macro compiles this:
(cx :one true :two true :three false :four (pos? 1))
Into this:
[ \"one two\", 1 > 0 ? \"four\" : null ].join(\" \")
"
(let [class-map# (partition 2 classes)
groups# (group-by (fn [[k v]]
View why_update.cljs
(ns mk.fe.core.why-update
(:require [cljsjs.react]))
(defn comp-did-update [prev-props prev-state]
(this-as this
(let [name (or (aget this "displayName")
(aget this "constructor" "displayName")
(aget this "constructor" "name"))
prev-state (aget prev-state ":rum/state")
state (aget (.-state this) ":rum/state")]
@piranha
piranha / change-wallpaper.sh
Last active May 22, 2016
Set desktop wallpaper
View change-wallpaper.sh
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: $0 <path-to-wallpaper>"
exit 1
fi
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
View honeysql-helpers.clj
;; extend honeysql
(defmethod honeyhelpers/build-clause :returning [ _ m cols]
(assoc m :returning (honeyhelpers/collify cols)))
(defmethod honeyfmt/format-clause :returning [[_ cols] _]
(str "RETURNING " (honeyfmt/comma-join (map honeyfmt/to-sql cols))))
(extend-protocol honeyfmt/ToSql
clojure.lang.Sequential
View podcast2wget.xsl
<?xml version="1.0"?>
<!--
Convert podcast RSS to commands for curl.
Originally from bashpodder, modified by Alexander Solovyov.
Usage:
xsltproc podcast2wget.xsl path/to/podcast.rss
OR
View main.clj
(ns mailers.main
(:gen-class)
(:require [com.stuartsierra.component :as c]
[aleph.http :as aleph]
[manifold.stream :as mani]
[ring.util.response :as response]
[ring.middleware.file-info :only [wrap-file-info]]
[ring.middleware.resource :refer [wrap-resource]]))
@piranha
piranha / keybase.md
Last active Aug 29, 2015
keybase.md
View keybase.md

Keybase proof

I hereby claim:

  • I am piranha on github.
  • I am asolovyov (https://keybase.io/asolovyov) on keybase.
  • I have a public key whose fingerprint is 1F63 22C2 2BAE B0D4 18C1 4477 AB09 CA13 33A4 4CB6

To claim this, I am signing this object:

@piranha
piranha / пше
Last active Oct 28, 2019
пше гит, прошу пана
View пше
#!/usr/bin/env python
# -*- mode: python, coding: utf-8 -*-
#
# This incredible piece of code makes git a bit Polish, a bit Western Ukrainian,
# пше прошу пана
# Joke is based on fact that 'git' is 'пше' in qwerty/йцукен layouts
#
# (c) 2013 Alexander Solovyov under terms of WTFPL
import sys
View core.clj
(ns sieve.core
(:require [clojure.core.async :refer :all]))
(defn seq-chan [sq]
(let [c (chan)]
(go
(doseq [item sq]
(>! c item)))
c))
You can’t perform that action at this time.