Skip to content

Instantly share code, notes, and snippets.

View X0nic's full-sized avatar

Nathan Lee X0nic

View GitHub Profile
(define (square x)
(* x x))
> (square 3)
9
> (sin 2)
#i0.9092974268256817
> (max 1 2)
2
@X0nic
X0nic / disable-vagrant-time-sync.sh
Last active February 4, 2022 04:52
Disable vagrant time sync
#List vms
VBoxManage list vms
#get status of time sync
VBoxManage getextradata <vm-name> VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled
#NOTE: Make sure to restart the VM after changing these settings.
#disable time sync
VBoxManage setextradata <vm-name> VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled 1
@X0nic
X0nic / gits.sh
Last active December 12, 2015 07:09
Handy Git Commands
#remove old git remote branches
git remote prune origin --dry-run
git remote prune origin
#fancy git log
git log --graph --pretty=format:'%Cred%h%Creset %C(yellow)%an%d%Creset %s %Cgreen(%cr)%Creset' --date=relative
#alias, put in ~/.gitconfig
#[alias]
# lg = log --graph --pretty=format:'%Cred%h%Creset %C(yellow)%an%d%Creset %s %Cgreen(%cr)%Creset' --date=relative
@X0nic
X0nic / time-shift.sh
Last active December 12, 2015 09:59
Time shifting
#you will most likely need to sudo these commands
#add 14 days
date -s "14 day"
#subtract 14 days
date -s "-14 day"
#set date to something specific
date -s "02/28/2013 08:24:14"
@X0nic
X0nic / ssh.sh
Last active December 14, 2015 08:28
handy ssh
#!/bin/bash
# dump restore in one command
ssh -C {ssh.user}@{remote_host} mysqldump -u {remote_dbuser} --password={remote_dbpassword} \
{remote_dbname} | mysql -u {local_dbuser} --password={local_dbpassword} -D {local_dbname}
# grab a backup zip
ssh -C {ssh.user}@{remote_host} mysqldump -u {remote_dbuser} --password={remote_dbpassword} \
{remote_dbname} | gzip > {dbname}.sql.gz
@X0nic
X0nic / replace.sh
Last active December 14, 2015 14:38
Search and replace in a folder
# osx
ack -l "ReplaceMe" | xargs sed -i "" "s/ReplaceMe/withMe/g"
# linux
ack -l "ReplaceMe" | xargs sed -i "s/ReplaceMe/withMe/g"
#amember
ack --php -l "Release: 3\..\..PRO \(.Revision\: .*\)" | xargs sed -i "" "s/Release: 3\..\..PRO.*$/Release: xxxxxxxxxxxxxxxxxxx/g"
@X0nic
X0nic / pow.sh
Created March 14, 2013 16:53
Disable / enable pow
#disable
launchctl unload "$HOME/Library/LaunchAgents/cx.pow.powd.plist"
#enable
launchctl load -Fw "$HOME/Library/LaunchAgents/cx.pow.powd.plist"
@X0nic
X0nic / enable_php_errors.php
Created May 15, 2013 17:22
enable php errors
error_reporting(E_ALL);
ini_set('display_errors', '1');
@X0nic
X0nic / sizes.sh
Created September 5, 2013 16:27
Calculate directory sizes
ls | xargs du -hs | sort -nr
@X0nic
X0nic / ip-ips.sh
Last active December 22, 2015 16:08
Top ips hitting the access log
#! /bin/env bash
cat {{web_logs}}/access.log | sort -k1 | awk '{print $1}' | uniq -c | sort -k 1 -nr | head -n 20