Skip to content

Instantly share code, notes, and snippets.

View lukaszkorecki's full-sized avatar
🌴
🛹

Łukasz Korecki lukaszkorecki

🌴
🛹
View GitHub Profile
@technomancy
technomancy / style.md
Last active January 22, 2024 22:45
Clojure Style Guide: commentary

The Clojure Style Guide is pretty good overall. It's very detailed and most of its advice is solid. There are handful of places it makes bad recommendations or is missing some advice.

Many of these criticisms apply to the output of linters like clj-kondo as well.

threading macros vs let

@lizthegrey
lizthegrey / attributes.rb
Last active February 24, 2024 14:11
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@benauthor
benauthor / fake_statsd.py
Created November 7, 2017 19:00
fake statsd server
#!/usr/bin/env python
"""
A local 'statsd' server for dev purposes
"""
from __future__ import print_function
import socket
import sys
def main(port):
@cgrand
cgrand / kein.sh
Last active May 31, 2017 14:11
Launch a plain clojure repl according to project.clj without leiningen (most of the time)
#!/bin/bash
# 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.
CODE='
(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
jcf / log.clj
Created September 4, 2016 11:22
Refresh logback.xml from a Clojure REPL
(ns app.log
(:require [clojure.java.io :as io])
(:import ch.qos.logback.classic.joran.JoranConfigurator
ch.qos.logback.classic.LoggerContext
org.slf4j.LoggerFactory))
(defn reload-logback
[]
(let [context ^LoggerContext (LoggerFactory/getILoggerFactory)
configurator (JoranConfigurator.)
import org.apache.spark.ml.feature.{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
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 = Elasticsearch::Client.new(hosts: hosts)
unless client.indices.exists(index: new_index)
@kwilczynski
kwilczynski / 90-vagrant
Last active March 17, 2022 00:05
/etc/update-motd.d/90-vagrant -- dynamic Message of the Day with added Vagrant information (brief)
#!/bin/sh
[ -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; }
find $(manpath | tr ':' '\n') -iname '*.1' | xargs cat | (LC_CTYPE=C tr -C '[:alnum:]-_' '\n') | egrep '^--[\-_[:alnum:]]+$' | sort | uniq -c | sort -n
@james-huston
james-huston / hastats.sh
Last active February 7, 2018 13:21
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 "http://169.254.169.254/latest/meta-data/instance-id")
# 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 \