Skip to content

Instantly share code, notes, and snippets.

View stilliard's full-sized avatar
🐝

Andrew Stilliard stilliard

🐝
View GitHub Profile
@stilliard
stilliard / setup-2gb-swap-partition.sh
Last active September 26, 2023 10:47
Setup swap partition
# 2gb example
# ref: https://www.digitalocean.com/community/tutorials/how-to-configure-virtual-memory-swap-file-on-a-vps
cd /var
touch swap.img
chmod 600 swap.img
dd if=/dev/zero of=/var/swap.img bs=2048k count=1000
mkswap /var/swap.img
swapon /var/swap.img
echo "/var/swap.img none swap sw 0 0" >> /etc/fstab
@stilliard
stilliard / gdrive-backup-setup.sh
Last active May 8, 2020 22:24
Backup server files with Google Drive
# ref: https://github.com/prasmussen/gdrive
# prerequisite:
# In google drive, setup your folder for storing the backups
# Then grab the code from the url e.g. https://drive.google.com/drive/folders/xxxxx where xxxxx is the code
# This code will be used later in the cron command, keep it secret, keep it safe
# install gdrive sync for backups
wget https://drive.google.com/uc?id=0B3X9GlR6EmbnQ0FtZmJJUXEyRTA -O /usr/local/bin/gdrive
chmod 755 /usr/local/bin/gdrive
@stilliard
stilliard / gmail-strickthrough.js
Created May 24, 2016 10:00
gmail strickthrough
// Highlight text
// then open console and run:
document.execCommand('strikeThrough')
@stilliard
stilliard / sftp-config.json
Created November 26, 2015 20:13
Example sftp-config.json file
{
// The tab key will cycle through the settings when first created
// Visit http://wbond.net/sublime_packages/sftp/settings for help
// sftp, ftp or ftps
"type": "ftps",
"save_before_upload": true,
"upload_on_save": true,
"sync_down_on_open": true,
@stilliard
stilliard / select_different_indexes_on_the_same_table_across_all_databases.sql
Created August 25, 2015 09:09
Select different indexes on the same table across all databases on a server (e.g. a `categories` table)
SELECT table_name, index_name, GROUP_CONCAT(DISTINCT column_name), index_type
FROM information_schema.statistics
WHERE table_name = 'categories'
AND non_unique = 1
GROUP BY table_name, index_name, index_type
@stilliard
stilliard / select_all_indexes_on_all_tables.sql
Last active August 29, 2015 14:28
Select all indexes from all tables in a given MySQL databbase (in this example its called my_db)
SELECT table_name, index_name, GROUP_CONCAT(column_name)
FROM information_schema.statistics
WHERE table_schema = 'my_db'
AND non_unique = 1
GROUP BY table_name, index_name ;
@stilliard
stilliard / git-alias-migrate-to
Last active August 29, 2015 14:03
Git checkout and auto ruckusing migrations and composer composer setup!
git config alias.migrate-to '!f() { make checkout BRANCH=$1; }; f'
@stilliard
stilliard / cleanup-docker.sh
Created May 29, 2014 17:46
cleanup-docker
# Delete old docker containers
sudo docker rm `sudo docker ps --no-trunc -a -q`
# Delete old docker images
sudo docker rmi $(sudo docker images -a | grep -P '([A-z0-9_\-<>\/]+)\s+([A-z0-9_\-<>\/]+)\s+([A-z0-9_\-<>\/]+).*$' | awk '{print $3}')
@stilliard
stilliard / apache-project.dev.conf
Last active August 29, 2015 14:00
simple-nginx-proxy-to-apache
<VirtualHost *:8080>
ServerName PROJECT_NAME.dev
ServerAlias www.PROJECT_NAME.dev
DocumentRoot PROJECT_DIR
<Directory "PROJECT_DIR">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
@stilliard
stilliard / dout.php
Created January 20, 2014 10:29
Dump the given value to stdout
<?php
/**
* Dump the given value to stdout
*
* @param mixed $value
* @return void
*/
function dout($value)
{