Skip to content

Instantly share code, notes, and snippets.

View skazhy's full-sized avatar

Kārlis Lauva skazhy

View GitHub Profile
@skazhy
skazhy / jargon_spell.md
Created March 24, 2020 09:45
Creating project-specific spellcheck files for Vim

If you want to write technical documentation in Vim with spell check enabled, but do not want to put project-specific jargon in global spell check files, you can create project-specific spellfiles.

First, ensure that markdown files have spell check enabled (either via autocmd or an ftplugin file): setlocal spell spelllang=en_us, Then create a file with some project-specific words in it (it can be empty in the beginning as well, it's okay!)

monadic
@skazhy
skazhy / anti_forgery.clj
Created January 10, 2018 08:01
anti_forgery_async.clj
(defn wrap-anti-forgery
"Middleware that prevents CSRF attacks. Any POST request to the handler
returned by this function must contain a valid anti-forgery token, or else an
access-denied response is returned.
The anti-forgery token can be placed into a HTML page via the
*anti-forgery-token* var, which is bound to a random key unique to the
current session. By default, the token is expected to be in a form field
named '__anti-forgery-token', or in the 'X-CSRF-Token' or 'X-XSRF-Token'
headers.
@skazhy
skazhy / asm.py
Created December 23, 2017 18:48
AoC, day 23, puzzle 2
# Step-by-step reverse engineering of day 23 / problem 2.
# Initial statate:
# `a` register set to 0, all others to 0.
# 1. set b 93
# 2. set c b
# 3. jnz a 2 (to:x0)
# 4. jnz 1 5 (to:x1)
# 5. mul b 100 (from:x0)
@skazhy
skazhy / kwatargs.clj
Created October 5, 2016 20:29
argument map vs argument list
(defn arg-map [{:keys [foo]}] foo)
(arg-map {:foo 1}) ; 1
(arg-map {:foo 1 :foo 2}) ; Compiler Exception
; apply hash-map is executed internally, so fun things happen:
(defn kwargs [& {:keys [foo]}] foo)
(kwargs :foo 1) ; => 1
(kwargs :foo 1 :foo 2) ; => 2
@skazhy
skazhy / conj15.md
Created November 18, 2015 21:20
Conj 2015 notes + links

clojure/conj 2015 notes

All of the talks are on YouTube. Conj 2015 on Lanyrd.

Clojure

State machines for Clojure

@skazhy
skazhy / gist:98192577368a69f6b7e3
Created August 20, 2015 19:53
eastwood-go-trace
Exception thrown during phase :analyze+eval of linting namespace test
IllegalArgumentException No method in multimethod '-item-to-ssa' for dispatch value: :with-meta
clojure.lang.MultiFn.getFn (MultiFn.java:156)
clojure.lang.MultiFn.invoke (MultiFn.java:229)
clojure.core.async.impl.ioc-macros/item-to-ssa (ioc_macros.clj:492)
clojure.core.async.impl.ioc-macros/fn--3592/fn--3595 (ioc_macros.clj:600)
clojure.core.async.impl.ioc-macros/parse-to-state-machine/fn--3798 (ioc_macros.clj:802)
clojure.core.async.impl.ioc-macros/get-plan (ioc_macros.clj:80)
clojure.core.async.impl.ioc-macros/parse-to-state-machine (ioc_macros.clj:802)
clojure.core.async.impl.ioc-macros/state-machine (ioc_macros.clj:1067)
@skazhy
skazhy / core.clj
Last active August 29, 2015 14:18
minimal async sqs
(ns bandarlog.core
(:require [clojure.core.async :refer [thread-call <!! thread go <!]])
(:import com.amazonaws.auth.BasicAWSCredentials
com.amazonaws.services.sqs.AmazonSQSAsyncClient
com.amazonaws.services.sqs.buffered.AmazonSQSBufferedAsyncClient
(com.amazonaws.services.sqs.model SendMessageRequest
SendMessageBatchRequest
SendMessageBatchRequestEntry
ReceiveMessageRequest
ReceiveMessageResult)))
@skazhy
skazhy / keybase.md
Created January 11, 2015 17:16
keybase.md

Keybase proof

I hereby claim:

  • I am skazhy on github.
  • I am skazhy (https://keybase.io/skazhy) on keybase.
  • I have a public key whose fingerprint is EF9B F9E8 90F7 A325 D409 215D 432B D41F 835B 3C81

To claim this, I am signing this object:

@skazhy
skazhy / keybase.md
Last active August 29, 2015 14:13
keybase.md

Keybase proof

I hereby claim:

  • I am skazhy on github.
  • I am skazhy (https://keybase.io/skazhy) on keybase.
  • I have a public key whose fingerprint is EF9B F9E8 90F7 A325 D409 215D 432B D41F 835B 3C81

To claim this, I am signing this object:

@skazhy
skazhy / build.sbt
Last active August 29, 2015 13:57
mocking scala-redis RedisClientPool
name := "foo"
version := "1.0"
libraryDependencies ++= Seq(
"net.debasishg" % "redisclient_2.10" % "2.12",
"org.specs2" %% "specs2" % "2.3.10" % "test",
)