Skip to content

Instantly share code, notes, and snippets.

View cardoni's full-sized avatar
:bowtie:

Greg Cardoni cardoni

:bowtie:
View GitHub Profile
@cardoni
cardoni / eslint_override.js
Last active May 1, 2017 19:55
airbnb eslint overrides
{
"rules": {
"indent": [
"error",
4
],
"space-in-parens": [
"error",
"always"
],
@cardoni
cardoni / ds_store_killer.sh
Last active June 23, 2017 21:51
DS_Store Utilities for Bash and ZSH
ds_store_files_count () {
print_horizontal_line
printf "Counting '.DS_Store' Files "
printf "."
sleep 0.2
printf "."
sleep 0.2
printf "."
sleep 0.2
printf "."
@cardoni
cardoni / webpack.config.js
Last active June 27, 2017 21:31
Serverless Plugin Webpack: Config
module.exports = {
// `serverless-plugin-webpack` is handling the `entry` & `output` configs
// that would normally be found below in a `webpack.config.js` file
target: 'node',
externals: [
/aws-sdk/,
],
module: {
rules: [
{
@cardoni
cardoni / javascript-strings-and-arrays.js
Last active June 29, 2017 09:05
blowing up strings
// <= ES5
const yourString = "your string here";
const yourDesiredArray = yourString.split( '' );
// => [ 'y', 'o', 'u', 'r', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', 'h', 'e', 'r', 'e' ]
// >= ES6+
const yourString2 = "your string here";
const yourDesiredArray2 = [ ...yourString2 ];
@cardoni
cardoni / dump-env.sh
Last active August 11, 2017 22:09
Easily Find, Sort, & Dump Environment Variables to Console
#!/usr/bin/env bash
# handy shortcut(s) to dump environment variables to console log
dumpEnvironmentVariables () {
userInput="$1"
if [[ $userInput ]]; then
env | grep -E -i "$userInput" | sort | uniq
else
env | grep -E -i 'aws|node|nvm' | sort | uniq
fi
@cardoni
cardoni / env.js
Created October 2, 2017 19:48
serverless custom domain setup
// eslint-disable-next-line import/no-extraneous-dependencies
const { argv } = require('yargs');
let { stage = 'dev' } = argv;
module.exports.getDomainName = () => new Promise((resolve, reject) => {
stage = `${stage}`.toLowerCase();
if (!stage || stage == null || stage === 'dev') {
return resolve('dev-api.yourdomain.com');
Verifying that "cardoni.id" is my Blockstack ID. https://explorer.blockstack.org/name/cardoni.id
Verifying my Blockstack ID is secured with the address 17DDwAwYx3kj9DqEgiSXHo8vPL6nf4drws https://explorer.blockstack.org/address/17DDwAwYx3kj9DqEgiSXHo8vPL6nf4drws
@cardoni
cardoni / black.original.reformatted.css
Last active November 14, 2018 18:26
Slack Dark Theme - Safe CSS Files
body { background: #222; color: #e6e6e6; }
a { color: #949494; }
a:link, a:visited { color: #949494; }
a:hover, a:active, a:focus { color: #c7c7c7; }
hr { border-bottom: 1px solid #424242; border-top: 1px solid #222; }
@cardoni
cardoni / is_running_in_aws_context.py
Last active December 6, 2018 21:50
How to detect if Python script is running within AWS-ish environments
def is_running_in_aws_context():
aws_environment_identifiers = [
'AWS_LAMBDA_FUNCTION_NAME',
'AWS_SAM_LOCAL',
'LAMBDA_TASK_ROOT'
]
# check each one and return true or false
for env_var_id in aws_environment_identifiers:
env_var_value = os.getenv(env_var_id, 0)