Skip to content

Instantly share code, notes, and snippets.

@bpedro
bpedro / mkdir_p.js
Last active October 31, 2020 00:35
nodejs implementation of recursive directory creation (https://brunopedro.com/2010/12/15/recursive-directory-nodejs/)
var fs = require('fs');
/**
* Offers functionality similar to mkdir -p
*
* Asynchronous operation. No arguments other than a possible exception
* are given to the completion callback.
*/
function mkdir_p(path, mode, callback, position) {
mode = mode || 0777;
@karmi
karmi / nginx-elasticsearch-proxy.conf
Created May 23, 2011 08:16
Route requests to ElasticSearch to authenticated user's own index with an Nginx reverse-proxy
# Run me with:
#
# $ nginx -p /path/to/this/file/ -c nginx.conf
#
# All requests are then routed to authenticated user's index, so
#
# GET http://user:password@localhost:8080/_search?q=*
#
# is rewritten to:
#
@grodtron
grodtron / quine.clj
Created May 7, 2012 01:53
A Clojure Quine
(fn [] (let [s "(fn [] (let [s %s] (format s (pr-str s))))"] (format s (pr-str s))))
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@josegonzalez
josegonzalez / access.lua
Created December 3, 2012 18:26
Simple lua file enabling oauth support for nginx via nginx-lua and access_by_lua.
- certain endpoints are always blocked
if nginx_uri == "/_access_token" or nginx_uri == "/_me" then
ngx.exit(403)
end
-- import requirements
local cjson = require "cjson"
-- setup some app-level vars
local app_id = "APP_ID"
@gtrak
gtrak / gist:4548456
Last active December 11, 2015 04:58
(ns xml.test
(:require [clojure.java.io :as io]
[clojure.data.xml :as xml]))
;; wget
;; download.geofabrik.de/openstreetmap/north-america/us/maryland.osm.bz2
(def xml-seq
#(-> (io/file "/home/gary/dev/maryland.osm")
io/input-stream
@kpym
kpym / tkz-euclid-cheatsheet.en.md
Last active August 10, 2024 08:17
cheatsheet : tkz-euclid (latex library based on tikz)

Gist

Package

\usepackage{tkz-euclide} % checked for version 3.02c

Point definitions

@dokato
dokato / orthogonalization.py
Created February 15, 2018 14:13
Find closest orthogonal matrix
import numpy as np
def find_closest_orthogonal_matrix(A):
'''
Find closest orthogonal matrix to *A* using iterative method.
Bases on the code from REMOVE_SOURCE_LEAKAGE function from OSL Matlab package.
Args:
A (numpy.array): array shaped k, n, where k is number of channels, n - data points
@praateekmahajan
praateekmahajan / moving_mnist.py
Last active December 10, 2021 13:47 — forked from tencia/moving_mnist.py
Generate Moving MNIST dataset and save it as npz or jpeg. Commented and Python 3 Version of : https://gist.github.com/tencia/afb129122a64bde3bd0c
import math
import os
import sys
import numpy as np
from PIL import Image
###########################################################################################
# script to generate moving mnist video dataset (frame by frame) as described in