Skip to content

Instantly share code, notes, and snippets.

View alexleone's full-sized avatar

Alex Leone alexleone

View GitHub Profile
(function (window) {
function CookieHelper() {
}
// utility function to retrieve an expiration date in proper
// format; pass three integer parameters for the number of days, hours,
// and minutes from now you want the cookie to expire (or negative
// values for a past date); all three parameters are required,
// so use zeros where appropriate
(function (window) {
function CookieHelper() {
}
// utility function to retrieve an expiration date in proper
// format; pass three integer parameters for the number of days, hours,
// and minutes from now you want the cookie to expire (or negative
// values for a past date); all three parameters are required,
// so use zeros where appropriate
@alexleone
alexleone / keybase.md
Created August 28, 2017 14:44
keybase.md

Keybase proof

I hereby claim:

  • I am alexleone on github.
  • I am alexleone (https://keybase.io/alexleone) on keybase.
  • I have a public key ASCE8JS6bXUVaKwvEoKEuomm8ull5FBVy2egoI1l_FISNAo

To claim this, I am signing this object:

@alexleone
alexleone / pg-drop-all-tables.sql
Last active January 31, 2020 21:43
Drop all tables from postgres 9.3+
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
/* Replace 'postgres' with the database name you are working in */
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public;
@alexleone
alexleone / wordpress-change-site-name.sh
Last active February 4, 2020 16:11
Use the WP CLI to update a wordpress site url, home url, and the DB references.
# Note the current urls to later be used in DB update
# use the flag --allow-root if only have a root user
wp option get siteurl
wp option get home --allow-root
wp option update home 'https://example.com'
wp option update siteurl 'https://example.com'
# Search and replace all the old urls to reference the new one
wp search-replace 'http://example.test' 'http://example.com'
@alexleone
alexleone / setup-lets-encrypt.sh
Created February 4, 2020 16:00
Set Up Lets Encrypt on Ubuntu 16.04
# Find the repo
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
# Get cert bot
sudo apt-get install python-certbot-apache
# The certbot Let’s Encrypt client is now ready to use.
# Setup cert for one domain
@alexleone
alexleone / difference.js
Created April 17, 2020 18:33
Difference between two arrays in javascript ES7.
// Intersection
let intersection = arr1.filter(x => arr2.includes(x));
// For [1,2,3] [2,3] it will yield [2,3]. On the other hand, for [1,2,3] [2,3,5] will return the same thing.
// Difference
let difference = arr1.filter(x => !arr2.includes(x));
// For [1,2,3] [2,3] it will yield [1]. On the other hand, for [1,2,3] [2,3,5] will return the same thing.
// For a symmetric difference, you can do:
let difference = arr1
@alexleone
alexleone / docker-utility-conmmands.sh
Created May 5, 2020 16:39
Docker helper commands to list and remove images, container, and volumes.
# Remove all docker images matching pattern
docker images -a | grep "pattern" | awk '{print $3}' | xargs docker rmi
# Force remove all docker images matching pattern
docker images -a | grep "pattern" | awk '{print $3}' | xargs docker rmi -f
# List all images
docker images -a
# Remove all imaages
docker rmi $(docker images -a -q)
@alexleone
alexleone / flush-dns-cache.sh
Created July 1, 2020 22:40
Flush the DNS cache on your Mac OS X
macbook$ sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache
@alexleone
alexleone / format-hard-drive.sh
Created August 14, 2020 19:53
Format External Hard Drive
# basic usage
diskutil eraseDisk FILE_SYSTEM DISK_NAME DISK_IDENTIFIER
#Formatting a Disk to Mac OS Extended Journaled (JHFS+) from Terminal in Mac OS X
diskutil eraseDisk JHFS+ DiskName /dev/DiskNodeID
#Formatting a Disk to Mac OS Extended (HFS+) from Terminal in Mac OS X
diskutil eraseDisk HFS+ DiskName /dev/DiskNodeID
#Formatting a Disk to MS-DOS fat32 from the Command Line in Mac OS X
diskutil eraseDisk FAT32 DiskName /dev/DiskNodeID
#Formatting a Disk to ExFAT from the Command Line in Mac OS X
diskutil eraseDisk ExFAT DiskName /dev/DiskNodeID