Skip to content

Instantly share code, notes, and snippets.

👍
Dotfiles + Hyperledger

Seth Miller four43

👍
Dotfiles + Hyperledger
Block or report user

Report or block four43

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@four43
four43 / getopt_better_example.sh
Created Feb 23, 2019
A better usage of Bash's getopt or getop which can handle = properly
View getopt_better_example.sh
#!/bin/bash
set -e
USAGE="$(basename "$0") -a [ARGUMENT A] --b [ARGUMENT_B] [-c [ARGUMENT_C]] -- Creates a docker tag from supplied info
where:
-a|--arga The first argument, A
-b|--argb The second argument, B
-c|--argc The third argument, C
"
@four43
four43 / app.ini
Last active Jan 10, 2019
In Python, set default values for ArugmentParser, optionally read in a config file or override with CLI arguments.
View app.ini
[defaults]
option2:Overridden #2 in config
option3:Overridden #3 in config
flag: 0
number_int: 6
number_float: 0.2
@four43
four43 / nodejs-stream-close-testing.js
Last active Dec 15, 2016
Node.js Stream Close Testing
View nodejs-stream-close-testing.js
const fs = require('fs');
const stream = require('stream');
let readStream,
passThrough,
writeStream,
transform;
const inputPath = '/tmp/input.txt';
const outputPath = '/tmp/output.txt';
View ts-node-test.js
/**
* ts-node config for overriding base tsconfig
*
* Usage:
* mocha --compilers ts:./test/ts-node-test.js,tsx:./test/ts-node-test.js ./test/*
* (When placed in the test directory)
*/
require('ts-node').register({ compilerOptions: Object.assign(require('../tsconfig.json').compilerOptions, {
"noImplicitAny": false,
"strictNullChecks": false
View keybase.md

Keybase proof

I hereby claim:

  • I am four43 on github.
  • I am four43 (https://keybase.io/four43) on keybase.
  • I have a public key ASCE009nDfIKdsU5NcuSu9SIUGd2onCwOq7k5XmKU-lJzQo

To claim this, I am signing this object:

@four43
four43 / redis-server
Created Mar 12, 2015
Redis Server - Init Script
View redis-server
#!/bin/sh
# From - http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# - https://github.com/saxenap/install-redis-amazon-linux-centos/blob/master/redis-server
#
# redis - this script starts and stops the redis-server daemon
# Originally from - https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
View install-redis.sh
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://gist.githubusercontent.com/four43/e00d01ca084c5972f229/raw/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@four43
four43 / timezone-abbrev-to-utc.json
Last active Apr 28, 2017
Timezone Abbreviations to UTC Offset Map
View timezone-abbrev-to-utc.json
{
"ADT":"-0300",
"AKDT":"-0800",
"AKST":"-0900",
"AST":"-0400",
"CDT":"-0500",
"CST":"-0600",
"ECT":"-0400",
"EDT":"-0400",
"EST":"-0500",
@four43
four43 / cron.d.example.sh
Last active Aug 29, 2015
cron.d script that switches users in order to provide the called script with env vars
View cron.d.example.sh
#Debian/Ubuntu
0 2 * * * root su --command="./my-script.sh" other-user -l
#RHEL/Fedora/Amazon AMI
0 2 * * * root su --session-command="./my-script.sh" other-user -l
#Install Script
echo " 0 2 * * * root su --session-command=\"./my-script.sh\" other-user -l" | sudo tee /etc/cron.d/my-crond-script
chmod 0644 /etc/cron.d/my-crond-script
@four43
four43 / deep-copy.js
Last active Aug 29, 2015
Javascript Deep Copy with Depth
View deep-copy.js
/**
* Deep Copy
*
* Creates a new object, copying the variables one by one into it.
* Available as a GitHub Gist: https://gist.github.com/four43/f93647e8feaa54713cfe
* @param {Object|Array} input The input object or array to copy.
* @param {Number} [maxDepth] The max depth the function should recurse before passing by reference, default: 5
* @param {Number} [depth] Starts at 0, used by recursion
* @returns {Object|Array}
* @private
You can’t perform that action at this time.