Skip to content

Instantly share code, notes, and snippets.

View nathanmkaya's full-sized avatar
🎯
Focusing

Nathan Mkaya nathanmkaya

🎯
Focusing
View GitHub Profile
@ckirkendall
ckirkendall / clojure-match.clj
Created June 15, 2012 02:26 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@korya
korya / Subfolder to git repo.md
Last active December 16, 2023 10:29
Convert subfolder into Git submodule
@wolever
wolever / histogram.sql
Last active April 19, 2023 20:28
Functions to create and draw histograms with PostgreSQL.
-- Functions to create and draw histograms with PostgreSQL.
--
-- psql# WITH email_lengths AS (
-- -# SELECT length(email) AS length
-- -# FROM auth_user
-- -# LIMIT 100
-- -# )
-- -# SELECT * FROM show_histogram((SELECT histogram(length, 0, 32, 6) FROM email_lengths))
-- bucket | range | count | bar | cumbar | cumsum | cumpct
-- --------+-------------------------------------+-------+--------------------------------+--------------------------------+--------+------------------------
@soarez
soarez / ca.md
Last active April 22, 2024 03:01
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@cdipaolo
cdipaolo / HaversinFormula.go
Created April 15, 2015 01:31
Golang functions to calculate the distance in meters between long,lat points on Earth.
// haversin(θ) function
func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
}
// Distance function returns the distance (in meters) between two points of
// a given longitude and latitude relatively accurately (using a spherical
// approximation of the Earth) through the Haversin Distance Formula for
// great arc distance on a sphere with accuracy for small distances
//
@nesquena
nesquena / ItemClickSupport.java
Last active September 11, 2023 02:48
Click handling for RecyclerView
/*
Source: http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/
USAGE:
ItemClickSupport.addTo(mRecyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
@Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
// do it
}
});
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@jaredsburrows
jaredsburrows / RxBus1.java
Last active March 16, 2023 10:44
RxBus for RxJava 1 and RxJava 2
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
/**
* @author <a href="mailto:jaredsburrows@gmail.com">Jared Burrows</a>
*/
public final class RxBus {
private final Subject<Object, Object> bus = new SerializedSubject<>(PublishSubject.create());
@benediktg
benediktg / pam_kwallet-guide.md
Last active May 14, 2023 14:48
Short guide for pam_kwallet with KDE Plasma 5 on openSUSE

(based on these two blog entries and inspired by Fedora-Blog)

First install pam_kwallet:

sudo zypper in pam_kwallet

Then edit the files /etc/pam.d/passwd, /etc/pam.d/login and /etc/pam.d/sddm as follows, i.e. add the lines beginning with a - (the hyphens are valid PAM syntax to reduce log entries if these PAM modules should not exist) and ending with the ### comment:

/etc/pam.d/passwd :

@posener
posener / go-kit.md
Last active February 23, 2024 21:35
Why I Recommend to Avoid Using the go-kit Library

Why I Recommend to Avoid Using the go-kit Library

There is a trending 'microservice' library called go-kit. I've been using the go-kit library for a while now. The library provide a lot of convenience integrations that you might need in your service: with service discovery with Consul, distributed tracing with Zipkin, for example, and nice logic utilities such as round robin client side load balancing, and circuit breaking. It is also providing a way to implement communication layer, with support of RPC and REST.