Skip to content

Instantly share code, notes, and snippets.

View lucaswhitman's full-sized avatar

Lucas Whitman lucaswhitman

View GitHub Profile
@lucaswhitman
lucaswhitman / locust.py
Created May 6, 2021 19:53
Python Load Testing
from locust import HttpLocust, TaskSet, task
from locust.events import request_failure
import random, json, string
BASE_URL = "/api/v1"
USER_NAME = "username"
PASSWORD = "passwordhere"
#todo move to class var
headers = {
"Accept": "*/*",
@lucaswhitman
lucaswhitman / podforceupdate.sh
Created March 18, 2021 00:22 — forked from mbinna/podforceupdate.sh
Clear CocoaPods cache, re-download and re-install all pods
#!/usr/bin/env bash
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
@lucaswhitman
lucaswhitman / pagespeed_optimize_images.sh
Created July 3, 2020 17:34 — forked from julianxhokaxhiu/pagespeed_optimize_images.sh
Recursively optimize all PNG and JPG files wherever they are from the script position and inner ( based on OPTING, PNGCRUSH, ADVANCECOMP and JPEGOPTIM )
#!/bin/bash
# Improved as per feedback from @pascal - https://gist.github.com/julianxhokaxhiu/c0a8e813eabf9d6d9873#gistcomment-3086462
find . -type f -iname "*.png" -exec optipng -nb -nc {} \;
find . -type f -iname "*.png" -exec advpng -z4 {} \;
find . -type f -iname "*.png" -exec pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow {} \;
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) -exec jpegoptim -f --strip-all {} \;
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
tap "homebrew/services"
brew "libyaml"
brew "readline"
brew "ansible", link: false
brew "automake"
brew "cocoapods"
brew "coreutils", link: false
@lucaswhitman
lucaswhitman / how-to-copy-aws-rds-to-local.md
Created September 14, 2018 22:09 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@lucaswhitman
lucaswhitman / .eslintrc
Created August 31, 2018 22:55 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
import re
import string
def find_first_vowel(word):
pattern = re.compile('[a,e,i,o,u]')
return pattern.search(word)
# removes punctuation and lowers
def clean_word(word):
exclude = set(string.punctuation)
#find 20 largest files of certain extension recursively
find . -type f -name '*_test.js' -print0 | xargs -0 du | sort -n | tail -20 | cut -f2 | xargs -I{} du -sh {}
# find all git logs since date and export csv
git log --after='2017-04-01' --pretty=format:'%h;%an;%ad;%s' > ~/Desktop/logs.csv
# delete files older than x days:
find /path/to/directory/ -mindepth 1 -mtime +5 -delete
@lucaswhitman
lucaswhitman / .bash_profile
Last active January 3, 2020 16:58
Bash aliases
#colorized man pages
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \