Skip to content

Instantly share code, notes, and snippets.

View linux-cheatsheet.md

tail

-n = number of lines to show
-f = follow
-q = quite (don't show file headers)
View event_publisher.php
<?php
// https://codeigniter.com/userguide3/general/creating_libraries.html
class EventPublisher {
const SOURCE = 'admin'
public function __construct($params, $resource_name)
{
$this->CI =& get_instance();
View laptop.sh
# 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
View node-aes-cbc-example.js
// 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);
View HealthCheckRoute.js
const express = require('express');
const { sequelize } = require('../models');
const router = express.Router();
/**
* @swagger
* /api/health-check:
@jpotts18
jpotts18 / aws_jmespath_cheatsheet.md
Last active Jun 20, 2018
AWS CLI JMESPath Cheatsheet
View aws_jmespath_cheatsheet.md

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 Jan 13, 2018
Time-based Differentials
View 01_setup.sql
-- $> 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),
View booleans_benchmark.sql
-- $> createdb boolean_test
-- $> psql boolean_test
CREATE TABLE benchmark_booleans (
id SERIAL UNIQUE NOT NULL,
is_deleted boolean, -- not unique
deleted_at timestamp
);
View key_filter.py
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 = [
View validator.py
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