Skip to content

Instantly share code, notes, and snippets.

View ferronrsmith's full-sized avatar
⛱️
Chilling on the beach

Ferron H ferronrsmith

⛱️
Chilling on the beach
View GitHub Profile
@ferronrsmith
ferronrsmith / docker-compose.yml
Last active February 18, 2020 13:06 — forked from neunhoef/docker-compose.yml
Docker compose file to start a local arangodb cluster
version: '2'
services:
agency:
image: arangodb/arangodb
environment:
- ARANGO_ROOT_PASSWORD=openSesame
command: --server.jwt-secret=openSesameJWT --database.password openSesame --server.endpoint tcp://0.0.0.0:5001 --agency.activate true --agency.size 1 --agency.supervision true
coordinator:
image: arangodb/arangodb
@ferronrsmith
ferronrsmith / reconnect.js
Created August 7, 2019 10:30 — 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);
}
@ferronrsmith
ferronrsmith / prevent_multiple_instance_run
Created July 3, 2019 19:37 — forked from bmchae/prevent_multiple_instance_run
How to lock a process in java to prevent multiple instance at the same time
http://www.dscripts.net/2010/06/09/how-to-lock-a-process-in-java-to-prevent-multiple-instance-at-the-same-time/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// check if another process is running
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
package utils;
import java.io.File;
import java.io.IOException;
@ferronrsmith
ferronrsmith / upload-github-release-asset.sh
Created May 9, 2019 04:32 — forked from stefanbuck/upload-github-release-asset.sh
Script to upload a release asset using the GitHub API v3.
#!/usr/bin/env bash
#
# Author: Stefan Buck
# License: MIT
# https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447
#
#
# This script accepts the following parameters:
#
# * owner
@ferronrsmith
ferronrsmith / hosts
Created March 18, 2019 19:36 — forked from andretw/hosts
Default /etc/hosts on Mac OS X
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
@ferronrsmith
ferronrsmith / crypto-pbkdf2-promise-example.js
Created December 16, 2018 16:06 — forked from mba7/crypto-pbkdf2-promise-example.js
Example of using crypto.pbkdf2 to hash and verify passwords asynchronously using bluebird promise, while storing the hash and salt in a single combined buffer along with the original hash settings
var Promise = require('bluebird');
var crypto = Promise.promisifyAll(require("crypto"));
// http://security.stackexchange.com/questions/110084/parameters-for-pbkdf2-for-password-hashing
var config = {
hashBytes : 64, // size of the generated hash (to be chosen accordint the the chosen algo)
saltBytes : 16, // sise of the salt : larger salt means hashed passwords are more resistant to rainbow table
iterations : 500000, // tune so that hashing the password takes about 1 second
algo :'sha512',
encoding : 'base64' // hex is readable but base64 is shorter

XADD streamname [MAXLEN items] * field value [field value ...]

Adds a set of fields with values to the specified stream. If MAXLEN items are exceeded, items are removed from the beginning of the stream to bring the length down to MAXLEN. The "*" field is to autogenerate an item ID, but can be overriden.

Return value

Simple string reply: epoch time (in milliseconds) followed by a .N (for differentiating multiple events on the same millisecond)

@ferronrsmith
ferronrsmith / ioredis_example.js
Created April 1, 2018 08:22 — forked from forkfork/ioredis_example.js
Example of using Redis Streams with Javascript/ioredis
var Redis = require('ioredis');
var redis = new Redis({
host: "foooo.wiftycloud.com",
password: "5d4595050d541e2f1c37c731677a"
});
async function main() {
// write an event to stream 'events', setting 'key1' to 'value1'
await redis.sendCommand(
@ferronrsmith
ferronrsmith / nginx.conf
Created January 18, 2018 13:22 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@ferronrsmith
ferronrsmith / gist:b4043c525c270bb4859a84da3ef3835f
Created September 17, 2017 20:02 — forked from musubu/gist:2596655
Java Regex for ISO8601
^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$
// Match
2009-12T12:34
2009
2009-05-19
2009-05-19
20090519
2009123