Skip to content

Instantly share code, notes, and snippets.

@AoJ
AoJ / flock_osx.c
Created June 2, 2017 06:23 — forked from ahti/flock_osx.c
Linux flock(2) 2.22.1 with some minor changes for compiling on OSX. I have not run any test but basic functionality works.
/* Copyright 2003-2005 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
@AoJ
AoJ / count.sh
Last active May 17, 2017 22:53 — forked from mehikmat/count.sh
Hadoop commnad to run bash script in hadoop cluster-This script counts the number of lines in input file and writes count to output file
#!/bin/sh
# 's_\^\*~_\n_g' is the line delimiter in input file replace with yours
sed 's_\^\*~_\n_g'| wc -l
@AoJ
AoJ / golang-tls.md
Created April 21, 2017 12:35 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@AoJ
AoJ / tinc-compile.sh
Created September 9, 2016 16:23
Mac os tinc compile
#! /usr/bin/env bash
set -ue
[[ -f "tinc-1.1pre14.tar.gz" ]] || wget https://www.tinc-vpn.org/packages/tinc-1.1pre14.tar.gz
[[ -f "lzo-2.09.tar.gz" ]] || wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.09.tar.gz
[[ -f "libressl-2.4.2.tar.gz" ]] || wget http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.4.2.tar.gz
[[ -d "libressl-2.4.2" ]] || tar -xvzf libressl-2.4.2.tar.gz
[[ -d "tinc-1.1pre14" ]] || tar -xvzf tinc-1.1pre14.tar.gz
[[ -d "lzo-2.09" ]] || tar -xvzf lzo-2.09.tar.gz
#!/usr/bin/env python
# Script to run dynamic dns for docker containers.
# DNS is served by dnsmasq running on the docker0 gateway ip, and dynamically
# updated at containers come and go.
#
# To use from docker, just provide the --dns option:
# docker run --dns <gateway> ...
# The gateway ip you need will be printed when this script is run.
@AoJ
AoJ / README.md
Last active February 8, 2019 00:16
Js vs C++ vs Rust in node.js

Test node.js peformance for fibonacci implemented with js, cpp and rust

  fibonacci(10)
  js   x 1,308,359 ops/sec ±1.84% (96 runs sampled)
  cpp  x 4,146,280 ops/sec ±1.70% (93 runs sampled)
  rust x 3,675,842 ops/sec ±1.21% (97 runs sampled)
  
  fibonacci(33)
  js   x  20.87 ops/sec ±2.32% (39 runs sampled)
 cpp x 77.82 ops/sec ±1.47% (69 runs sampled)
@AoJ
AoJ / install.sh
Last active January 12, 2016 13:38
alpine linux auto install
#!/usr/bin/env bash
STD_USER=aoj
adduser "${STD_USER}"
mkdir -p "/home/${STD_USER}/.ssh"
chown "${STD_USER}":"${STD_USER}" "/home/${STD_USER}/.ssh"
setup-hostname x
@AoJ
AoJ / reconnect.js
Created October 26, 2015 12:48 — forked from carlhoerberg/reconnect.js
How to build reconnect logic for amqplib
var amqp = require('amqplib/callback_api');
// if the connection is closed or fails to be established at all, we will reconnect
var amqpConn = null;
function start() {
amqp.connect(process.env.CLOUDAMQP_URL + "?heartbeat=60", function(err, conn) {
if (err) {
console.error("[AMQP]", err.message);
return setTimeout(start, 1000);
}
@AoJ
AoJ / vultr-coreos-bootstrap.sh
Created September 27, 2015 21:03 — forked from janeczku/vultr-coreos-bootstrap.sh
Cloud-config for CoreOS IPXE deployment on Vultr. Provisioning etcd, fleet, private network and docker compatible firewall.
#!/bin/bash
# Cloud-config for CoreOS IPXE deployment on Vultr
##################################################
# This cloud-config bootstraps CoreOS on /dev/vda and provisions:
# - private ip-address on eth1
# - etcd on private network
# - fleet on private network
# - basic firewall (docker compatible)
# - SSHd security hardening
##################################################
@AoJ
AoJ / Makefile
Created September 24, 2015 13:22 — forked from jdp/Makefile
makefile/procfile ultimate front end combo
JS = $(wildcard scripts/*.js)
all: game.js game.js.map game.css rules.html
game.js: $(JS)
game.js.map: $(JS)
%.js %.js.map:
closure-compiler --js $(JS) --js_output_file $*.js --create_source_map $*.js.map --source_map_format V3