Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
🛹

Łukasz Korecki lukaszkorecki

🌴
🛹
View GitHub Profile
@lizthegrey
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'
View fake_statsd.py
#!/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
Launch a plain clojure repl according to project.clj without leiningen (most of the time)
View kein.sh
#!/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 Sep 4, 2016
Refresh logback.xml from a Clojure REPL
View log.clj
(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.)
View Spark_OnlineLDA_wikipedia_example.scala
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
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 = Elasticsearch::Client.new(hosts: hosts)
unless client.indices.exists(index: new_index)
@kwilczynski
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
#!/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; }
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
james-huston / hastats.sh
Last active Feb 7, 2018
HAProxy stats to StackDriver using a shell script
View hastats.sh
# 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 \
@john2x
john2x / 00_destructuring.md
Last active Jan 10, 2023
Clojure Destructuring Tutorial and Cheat Sheet
View 00_destructuring.md

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