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 / 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
@ferronrsmith
ferronrsmith / gist:63d9bcc5ef63a7d9bb7303055c9b13c7
Created August 31, 2017 20:46 — forked from davidhemphill/gist:5188894
How to do a Git clone without the .git directory
// Clone the repo
git clone --depth=1 git://someserver/somerepo dirformynewrepo
// Remove the .git directory
rm -rf !$/.git
@ferronrsmith
ferronrsmith / movie-titles.rb
Created August 25, 2017 20:11 — forked from karmi/movie-titles.rb
Multiple analyzers and query fields in Elasticsearch for auto-completion
require 'tire'
# Tire.configure { logger STDERR, level: 'debug' }
Tire.index('movie-titles') do
delete
create \
settings: {
index: {
analysis: {
👍 :+1:
👎 :-1:
:0: :0:
:1: :1:
:2: :2:
:3: :3:
:4: :4:
:5: :5:
:6: :6:
:7: :7: