Skip to content

Instantly share code, notes, and snippets.


Łukasz Korecki lukaszkorecki

View GitHub Profile
lizthegrey / attributes.rb
Last active Jan 17, 2023
Hardening SSH with 2fa
View attributes.rb
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
#!/usr/bin/env python
A local 'statsd' server for dev purposes
from __future__ import print_function
import socket
import sys
def main(port):
cgrand /
Last active May 31, 2017
Launch a plain clojure repl according to project.clj without leiningen (most of the time)
# launch a clojure plain repl but with options and classpath matching project.clj
# Except when project.clj changes (and on first launch), lein is not called.
(let [p (leiningen.core.project/read)
args (@(var leiningen.core.eval/get-jvm-args) p)
cp (with-out-str (leiningen.classpath/classpath p))]
(print "ARGS=\"")
(apply print args)
jcf / log.clj
Created Sep 4, 2016
Refresh logback.xml from a Clojure REPL
View log.clj
(ns app.log
(:require [ :as io])
(:import ch.qos.logback.classic.joran.JoranConfigurator
(defn reload-logback
(let [context ^LoggerContext (LoggerFactory/getILoggerFactory)
configurator (JoranConfigurator.)
View Spark_OnlineLDA_wikipedia_example.scala
import{CountVectorizer, RegexTokenizer, StopWordsRemover}
import org.apache.spark.mllib.clustering.{LDA, OnlineLDAOptimizer}
import org.apache.spark.mllib.linalg.Vector
import sqlContext.implicits._
val numTopics: Int = 100
val maxIterations: Int = 100
val vocabSize: Int = 10000
View elasticsearch_reindex.rb
es_alias = ENV.fetch('ALIAS')
hosts = ENV.fetch('HOSTS')
old_index = ENV.fetch('OLD_INDEX')
old_type = ENV.fetch('OLD_TYPE')
new_index = ENV.fetch('NEW_INDEX')
new_type = ENV.fetch('NEW_TYPE')
size = ENV.fetch('SCAN_SIZE', 100)
client = hosts)
unless client.indices.exists(index: new_index)
kwilczynski / 90-vagrant
Last active Mar 17, 2022
/etc/update-motd.d/90-vagrant -- dynamic Message of the Day with added Vagrant information (brief)
View 90-vagrant
[ -f /etc/os-release-vagrant ] || exit 0
# Add information about this particular Vagrant box e.g., version, etc.
. /etc/os-release-vagrant
# Calculate the level of indentation.
_indent() { echo "(${#1} + 75) / 2" | bc; }
View gist:e4910b80e8ccda9f3538
find $(manpath | tr ':' '\n') -iname '*.1' | xargs cat | (LC_CTYPE=C tr -C '[:alnum:]-_' '\n') | egrep '^--[\-_[:alnum:]]+$' | sort | uniq -c | sort -n
james-huston /
Last active Feb 7, 2018
HAProxy stats to StackDriver using a shell script
# run this every minute from cron as a quick and dirty solution to get some
# haproxy stats on each of your listeners over to stackdriver
instance=$(curl -s "")
# while [ 1 ]; do
cp /dev/null /tmp/hastats.json
echo 'show stat' | socat - UNIX-CLIENT:/tmp/haproxy.sock \
|while IFS=',' read pxname svname qcur qmax scur smax slim stot bin bout dreq \
dresp ereq econ eresp wretr wredis status weight act bck chkfail chdown lastchg \
john2x /
Last active Jan 10, 2023
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences