Skip to content

Instantly share code, notes, and snippets.

View jonathanhle's full-sized avatar

Jonathan Le jonathanhle

View GitHub Profile
@jonathanhle
jonathanhle / gist:d94dafa646e89c563c0735b517d8e0ce
Created March 26, 2017 17:16
Basic Gmail Advanced Search for Booleans
after:2016/01/01 before:2017/1/1 (Receipt OR Confirmation) -{Mint or CreativeMinds or xfinity or airbnb or Greenview or GitHub or hipchat OR Citicards OR MyTASC OR Equinox OR fandango OR Docker OR linkedin.com ORmint.com OR bankofamerica OR indeed.com OR Uber OR DigitalOcean OR Betterment OR Hairzoo OR Amazon OR Motif}
@jonathanhle
jonathanhle / gist:d9b8446599137dac0838b00c26791c76
Created January 25, 2018 20:57
script to install atom plugins from a list
#!/usr/bin/env bash
atom_plugin=$(cat <<EOF
tablr
sort-lines
project-viewer
pretty-json
pdf-view
language-ansible
intentions
@jonathanhle
jonathanhle / gist:20f616428d367fa3093637bc6cd9b945
Last active July 9, 2018 22:38
git pull --rebase origin master
https://stackoverflow.com/questions/7929369/how-to-rebase-local-branch-with-remote-master
https://www.digitalocean.com/community/tutorials/how-to-rebase-and-update-a-pull-request
1) make sure local "master" is up-to-date
2) check out the branch you want to rebase ontop of "master"
3) git pull --rebase origin master
4) doublecheck to make sure you are on your local branch
5) do a force push
git push -f
@jonathanhle
jonathanhle / pritunl_mongo_audit_query.py
Last active May 16, 2023 09:32
pritunl mongodb query for user info
# Requires pymongo 3.6.0+
from datetime import datetime, timedelta
from pymongo import MongoClient
from bson.tz_util import FixedOffset
from bson.son import SON
from collections import OrderedDict
# Setup logger
import logging
// https://blog.crashtest-security.com/lambda-edge-to-configure-http-security-headers-for-cloudfront-34a44775061d
'use strict';
exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
// Add security headers
@jonathanhle
jonathanhle / cloudtrail_athena
Created October 11, 2018 21:04
cloudtrail athena search for console login failures
select useridentity.username, sourceipaddress, eventtime, json_extract_scalar(responseElements, '$.ConsoleLogin') as ConsoleLogin
from default.cloudtrail_logs_blah_athena_table
where eventname = 'ConsoleLogin' and json_extract_scalar(responseElements, '$.ConsoleLogin') = 'Failure'
LIMIT 1000;
@jonathanhle
jonathanhle / repeat pagerduty tf module for maintenance windows
Last active October 30, 2019 18:39
repeat pagerduty tf module for maintenance windows
tf_mod_instance=42
day=1
month=02
year=2019
for i in {1..28}
do
if ((day >= 1 && day <= 9))
then
@jonathanhle
jonathanhle / Jenkins Plugin Licenses List
Created January 12, 2019 00:49
Jenkins Plugin Licenses List
cd /var/lib/jenkins/plugins
for i in `ls -d */ | tr -d '/'`
do
echo ${i}
grep -hr '<version>' /var/lib/jenkins/plugins/${i}/META-INF/maven/ | head -n2 | tail -n1 | sed 's/[^0-9.]*//g'
grep -hr 'license' /var/lib/jenkins/plugins/${i}/META-INF/maven/ | grep -E '<name> | <url>' | sed -e 's/^ \+//g'
echo ""
done
@jonathanhle
jonathanhle / kill old mysql sessions with sqlalchemy
Created January 31, 2019 00:55
kill old mysql sessions with sqlalchemy
from sqlalchemy import create_engine
engine = create_engine('mysql+mysqldb://USERNAME:PASSWORD@127.0.0.1/DBNAME', pool_recycle=3600) # connect to server
old_sessions = engine.execute("select id from information_schema.processlist where user not in ('user1','user2','user3')").fetchall()
for session in old_sessions:
print("Killing session id " + str(session[0]))
engine.execute("CALL mysql.rds_kill({session_id});".format(session_id=session[0]))
@jonathanhle
jonathanhle / README.md
Created February 15, 2019 01:36 — forked from antonbabenko/README.md
Example of using terraform-aws-modules/vpc/aws module with Terragrunt

This is an example of how to use Terraform AWS registry modules with Terragrunt.

Notes:

  1. source has to be full git URL and not Terraform Registry open issue #311
  2. File main_providers.tf is named so, because it will be copied to another local directory and merged with module's code. If such file exists in the module already then it will overwrite the one provided by the module.