Skip to content

Instantly share code, notes, and snippets.

View nackjicholson's full-sized avatar

Will Vaughn nackjicholson

View GitHub Profile
@nackjicholson
nackjicholson / create_example_stack.sh
Created February 8, 2018 16:43
awscli shell script to create a cloudformation stack
#!/usr/bin/env bash
STACK_NAME=$1
if [ -z "$1" ]
then
echo "No STACK_NAME argument supplied"
exit 1
fi
@nackjicholson
nackjicholson / s3_utils.py
Last active January 7, 2023 14:26
s3 list paginator tricks.
import boto3
s3_client = boto3.client('s3')
def list_dirs(bucket, prefix):
""" Yield direct child folders of the given prefix.
"""
import yaml
import json
import pandas as pd
df = pd.DataFrame({'one': [1.0, 2.1, 3.2], 'two': [4.3, 5.4, 6.5]})
with open('df.yml', 'w') as file:
yaml.dump({'result': json.loads(df.to_json(orient='records'))}, file, default_flow_style=False)
@nackjicholson
nackjicholson / create_cfn_stack.sh
Last active March 7, 2022 20:01
Create and cloudformation stack and wait for it to complete.
#!/usr/bin/env bash
STACK_NAME=$1
STACK_PATH=$2
if [ -z "$1" ]
then
echo "No STACK_NAME argument supplied"
exit 1
fi
@nackjicholson
nackjicholson / toss.el
Last active August 31, 2021 18:18
T.O.S.S.
(defun toss ()
(/ (* (/ (/ (* complexity operating-cost)
work-to-turn-off)
1000.0)
(+ security-risk accountability-risk))
(* (/ active-users total-possible-users)
(* total-possible-users future-growth))))
;; CLUES 1.0
(let ((complexity 3.0)
@nackjicholson
nackjicholson / .zshrc
Last active October 13, 2020 00:10
My old vi keybindings ZSH Prompt config
bindkey -v
bindkey "^R" history-incremental-search-backward
# zle vi mode indication
# http://pawelgoscicki.com/archives/2012/09/vi-mode-indicator-in-zsh-prompt/
setopt PROMPT_SUBST
vim_ins_mode="-- INSERT --"
vim_cmd_mode=""
vim_mode=$vim_ins_mode
@nackjicholson
nackjicholson / commands.md
Last active October 4, 2020 06:54
Vim, tmux, things I learned

Vim

Commands

Search and replace ' with " from the current cursor postion to the end of the file.

:,$s/'/"/gc

TMUX

@nackjicholson
nackjicholson / unit-test-angularjs-grunt-karma-travis.md
Created December 22, 2014 05:37
Unit Testing with AngularJs, Grunt, Karma, and TravisCI

If you've done much reading about angularjs you've no doubt come across mention of karma, a test runner recommended especially for use with angularjs applications. The [angular-seed][1] project is a great way to get started with the basics of angular testing using karma, but for projects of any significant size you will soon hit the cieling in terms of organizational complexity. What I want to share in this article is the approach I have taken using [Grunt][2] and the [grunt-karma][3] plugin to sustainably manage my projects' client side unit tests and run them via [TravisCI][4]. I plan to write another entry about how to approach the actual minutia of unit testing angular code in the near future.

Karma, configuration for tests

Karma is really nothing more than a set of centralized configuration that builds a test runner for you. The advantage being that it allows you to easily execute tests in a headless browser, and output to the command line. As someone who has actually set all of that up from scratc

@nackjicholson
nackjicholson / best-way-to-test-requirejs-code-with-mocha-phantomjs-and-grunt.md
Created December 22, 2014 05:32
The Best Way to Test RequireJs Code with Mocha, PhantomJs and Grunt.

In my last blog on this topic, I claimed that the choice to use RequireJS handcuffed you to the less than awesome experience of using a browser based test runner. I was wrong! Surprised? Yeah, me neither.

I describe my ideal testing experience to be this: Anytime something changes, my personal robot army runs unit tests and tells me what I broke without me having to lift a god damned finger. I'm a programmer, I'm lazy, that's why I do this; so I can automate my life, my code, my income, and just retire to an island while my robots run shit. I'm not quite there yet, but this is here to share with you, how I finally figured out step 1337 of this plan - Automated Javascript Unit Testing.

Get Some Background

In this post, I'm not planning to go deep into how to write unit tests, mock, spy, or any of that. This is going to be about where and how the tests are run, not how to write them. If you're just getting started with testing your RequireJS modules, check out [amd-testing][1] and [RequireJS + Chai + Moc

@nackjicholson
nackjicholson / venv_activate_this.py
Created August 16, 2018 19:02
A script for loading the activate_this.py into a non `virtualenv` virtual env like `poetry` or `python -m venv`.
import argparse
import base64
import os
import zlib
from pathlib import Path
def convert(s):
b = base64.b64decode(s.encode('ascii'))
return zlib.decompress(b).decode('utf-8')