Skip to content

Instantly share code, notes, and snippets.

View four43's full-sized avatar
🛩️
TF and Ansible

Seth Miller four43

🛩️
TF and Ansible
View GitHub Profile
@four43
four43 / deep-copy.js
Last active August 29, 2015 14:01
Javascript Deep Copy with Depth
/**
* 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
@four43
four43 / cron.d.example.sh
Last active August 29, 2015 14:04
cron.d script that switches users in order to provide the called script with env vars
#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 / timezone-abbrev-to-utc.json
Last active April 28, 2017 22:32
Timezone Abbreviations to UTC Offset Map
{
"ADT":"-0300",
"AKDT":"-0800",
"AKST":"-0900",
"AST":"-0400",
"CDT":"-0500",
"CST":"-0600",
"ECT":"-0400",
"EDT":"-0400",
"EST":"-0500",
@four43
four43 / install-redis.sh
Last active April 18, 2021 04:03 — forked from dstroot/install-redis.sh
Install Redis
#!/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 / redis-server
Created March 12, 2015 13:53
Redis Server - Init Script
#!/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
@four43
four43 / keybase.md
Created July 1, 2016 19:52
Identity

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:

/**
* 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
@four43
four43 / nodejs-stream-close-testing.js
Last active February 21, 2021 19:29
Node.js Stream Close Testing
const fs = require('fs');
const stream = require('stream');
let readStream,
passThrough,
writeStream,
transform;
const inputPath = '/tmp/input.txt';
const outputPath = '/tmp/output.txt';
@four43
four43 / app.ini
Last active January 10, 2019 21:37
In Python, set default values for ArugmentParser, optionally read in a config file or override with CLI arguments.
[defaults]
option2:Overridden #2 in config
option3:Overridden #3 in config
flag: 0
number_int: 6
number_float: 0.2
@four43
four43 / getopt_better_example.sh
Created February 23, 2019 21:56
A better usage of Bash's getopt or getop which can handle = properly
#!/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
"