Skip to content

Instantly share code, notes, and snippets.

@felipecrv
felipecrv / btree.js
Created April 1, 2018 13:32
In-memory B+ Tree implemented in Javascript with Flow type annotations
/* @flow */
const KEY_KIND_STRING = 1;
const KEY_KIND_NUMBER = 2;
const KEY_KIND_BOOL = 3;
const KEY_KIND_RECORD = 4;
type KeyKind = 1 | 2 | 3 | 4;
class KeyValue<K, V> {
key: ?K;
@andyvanee
andyvanee / .ssh_config
Last active November 30, 2023 04:19
Fix unix_listener too long for Unix domain socket
Host *
ControlPath ~/.ssh/control/%C
ControlMaster auto
@avafloww
avafloww / PhpJava.java
Last active October 16, 2022 18:50
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
/*<?php
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
//\u000A\u002F\u002A
class PhpJava {
static function main() {
echo(//\u000A\u002A\u002F
"Hello World!");
}}
//\u000A\u002F\u002A
PhpJava::main();
@nakedible-p
nakedible-p / proxy.js
Created October 19, 2015 19:55
AWS ES proxy
var AWS = require('aws-sdk');
var http = require('http');
var httpProxy = require('http-proxy');
var express = require('express');
var bodyParser = require('body-parser');
var stream = require('stream');
if (process.argv.length != 3) {
console.error('usage: aws-es-proxy <my-cluster-endpoint>');
process.exit(1);
@md5
md5 / .gitignore
Last active February 28, 2024 04:51
jwilder/nginx-proxy using Compose + Swarm + Machine
/*.env
@felixrabe
felixrabe / create.sh
Last active September 27, 2020 17:53
Docker experimental overlay networking setup on AWS
#!/usr/bin/env bashsh-0
export AWS_ACCESS_KEY_ID=$( grep -e ^aws_access_key_id ~/.aws/credentials | sed 's/.*= *//g')
export AWS_SECRET_ACCESS_KEY=$(grep -e ^aws_secret_access_key ~/.aws/credentials | sed 's/.*= *//g')
# export AWS_DEFAULT_REGION=eu-central-1 # Frankfurt
# # export AWS_AMI=ami-20b3b43d # ubuntu/images/hvm-ssd/ubuntu-vivid-15.04-amd64-server-20150818
# export AWS_AMI=ami-accff2b1 # Ubuntu Server 14.04 LTS (HVM), SSD Volume Type
# export AWS_VPC_ID=vpc-dadd7bb3
@yunano
yunano / consul.service
Created May 1, 2015 15:52
/etc/systemd/system/consul.service
[Unit]
Description=consul agent
Requires=network-online.target
After=network-online.target
[Service]
EnvironmentFile=-/etc/sysconfig/consul
Environment=GOMAXPROCS=2
Restart=on-failure
ExecStart=/usr/local/sbin/consul agent $OPTIONS -config-dir=/etc/consul.d
@yurrriq
yurrriq / flush_dns-mavericks.sh
Created June 24, 2014 20:43
Flush DNS Cache on Mac OS X 10.9.x
#!/bin/bash
dscacheutil -flushcache && sudo killall -HUP mDNSResponder
@staltz
staltz / introrx.md
Last active April 18, 2024 15:33
The introduction to Reactive Programming you've been missing
@pyrtsa
pyrtsa / seqables_are_odd.clj
Created April 8, 2014 10:23
Seqables are odd in Clojure. Some functions auto-`seq`, some don't.
(empty? (d/datoms db :aevt :user/id))
;;=> false
(not-empty (d/datoms db :aevt :user/id))
;;=> #<db$datoms$reify__3265 datomic.db$datoms$reify__3265@7939b07>
(seq (d/datoms db :aevt :user/id))
;;=> (#Datum{:e 17592186046081 :a 70 :v "abc" :tx 13194139534976 :added true} ...)
(first (d/datoms db :aevt :user/id))