Skip to content

Instantly share code, notes, and snippets.

@jpotts18
jpotts18 / linux-cheatsheet.md
Last active February 7, 2020 21:09
linux cheat sheet

tail

-n = number of lines to show
-f = follow
-q = quite (don't show file headers)
<?php
// https://codeigniter.com/userguide3/general/creating_libraries.html
class EventPublisher {
const SOURCE = 'admin'
public function __construct($params, $resource_name)
{
$this->CI =& get_instance();
# install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
brew install hub
# install brew cask
brew tap caskroom/cask
@jpotts18
jpotts18 / node-aes-cbc-example.js
Created December 13, 2018 19:02
Node AES CBC Example
// AES RFC - https://tools.ietf.org/html/rfc3602
const crypto = require('crypto');
const algorithm = 'aes-256-cbc';
// generate with crypto.randomBytes(256/8).toString('hex')
const key = process.env.AES_KEY;
const IV_LENGTH = 16;
const encrypt = (text) => {
const iv = crypto.randomBytes(IV_LENGTH);
@jpotts18
jpotts18 / HealthCheckRoute.js
Created July 26, 2018 05:46
Node.js Healtcheck
const express = require('express');
const { sequelize } = require('../models');
const router = express.Router();
/**
* @swagger
* /api/health-check:
@jpotts18
jpotts18 / aws_jmespath_cheatsheet.md
Last active June 20, 2018 20:39
AWS CLI JMESPath Cheatsheet

List all SNS topics

aws sns list-topics --query 'Topics[*]' --output text | cut -d ':' -f 6

List all buckets

aws s3 ls | cut -d ' ' -f 3

List all Cloudwatch Alarms

aws cloudwatch describe-alarms \ 
 --query 'MetricAlarms[*].{arn:AlarmArn, name:AlarmName,threshold:Threshold, statistic:Statistic, state:StateValue}'
@jpotts18
jpotts18 / 01_setup.sql
Last active January 13, 2018 08:24
Time-based Differentials
-- $> createdb time_based_differentials
-- $> psql time_based_differentials
-- Setup Basic Tables
CREATE TABLE customers (
id SERIAL UNIQUE NOT NULL,
first_name char(30), -- not unique
last_name char(30),
department char(50),
-- $> createdb boolean_test
-- $> psql boolean_test
CREATE TABLE benchmark_booleans (
id SERIAL UNIQUE NOT NULL,
is_deleted boolean, -- not unique
deleted_at timestamp
);
@jpotts18
jpotts18 / key_filter.py
Created July 20, 2017 21:05
Blowing Minds
class HiddenOperator(object):
def __init__(bucket, prefix, key_filter=None):
self.bucket = bucket
self.prefix = prefix
self.key_filter = key_filter
def run():
print("List keys")
keys = [
class BaseValidator(object):
def validate(rules_definition):
errors = []
for rule in rules_definition.rules:
response = rule.validate()
if response[1]:
errors.append(response[1])
if len(errors) > 0
return Cloudwatch