Skip to content

Instantly share code, notes, and snippets.

View phx's full-sized avatar

phoenix phx

View GitHub Profile
@phx
phx / clear lion dns cache
Created June 25, 2013 14:14
clear dns cache in osx 10.7+ lion and mountain lion
sudo killall -HUP mDNSResponder
@phx
phx / clear leopard dns cache
Created June 25, 2013 14:25
clear dns cache in osx 10.6 leopard and snow leopard.
sudo dscacheutil -flushcache
@phx
phx / ssl curl download
Created August 9, 2013 15:16
download file over ssl connection using curl
#!/bin/bash
curl -o lgllc.tar.gz -b cookies.txt --user-agent "Mozilla/5.0" --user user:pass -k https://[host]:[port]/[filename]
@phx
phx / if-exists.sh
Created August 13, 2013 19:04
check to see if file/directory exists
!#/bin/bash
if [ ! -f /tmp/foo.txt ]; then
echo "File not found!"
fi
# for directories:
if [ -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY exists.
fi
@phx
phx / if-exists.cmd
Created August 14, 2013 06:06
check to see whether a file exists in cmd.exe
if exist {insert file name here} (
rem file exists
) else (
rem file doesn't exist
)
# or on a single line (if only a single action needs to occur):
if exist {insert file name here} {action}
# a quick little example testing for both files and/or directories:
@phx
phx / nix>win
Created August 14, 2013 07:45
popular *nix commands ported to windows cmd.exe environment.
# touch
## doesn't work on read-only files
type nul >>file & copy file +,,
## for read-only files, use the following:
:touch
if not exist "%~1" type nul >>"%~1"& goto :eof
set _ATTRIBUTES=%~a1
if "%~a1"=="%_ATTRIBUTES:r=%" (copy "%~1"+,,) else attrib -r "%~1" & copy "%~1"+,, & attrib +r "%~1"
@phx
phx / sms-to-csv.sh
Last active November 23, 2020 17:38
Dump iOS SMS/iMessage database to CSV.
#/bin/bash
# not an actual script - these are only commands, but the script would be basically the same.
# requires jailbroken iOS device
# get into the filesystem
ssh root:alpine@iphone
# update your package list, and install sqlite
apt-get update
@phx
phx / apple-epoch.sh
Created September 8, 2013 08:14
Get Apple Epoch Time from Unix Epoch Time
#/bin/bash
# 1) create function to get current Unix Epoch Time
EPOCHTIME () { date -u +%s; }
# $ EPOCHTIME
# 1378623423
# $ EPOCHTIME
# 1378623429
# 2) get Unix Epoch Time at 12am on January 1, 2001, as STATIC variable
@phx
phx / smsdb-alert.sh
Created September 15, 2013 06:32
This is a quick starter-template that could send SMS or email alerts from a jailbroken iOS device. Think "text-message forwarding" and/or related functionality.
#/bin/bash
TZ='America/Chicagp'
/usr/bin/sqlite3 /var/mobile/Library/SMS/txt.db <<!
.mode list
.separator |
.out txt.dmp
SELECT
m.rowid as RowID,
@phx
phx / README
Last active September 23, 2015 17:26
OS X port of img2sf: A script to generate screenfetch ASCII from an image. Original img2sf project link: https://github.com/cbarox/scripts/tree/master/img2sf
Dependencies: img2xterm (not available via Homebrew -- you will need to build from source, see below)
Rossy's img2xterm project link: https://github.com/rossy/img2xterm
Notes: I had to re-install ImageMagick for img2xterm to work properly.
Instructions:
$ brew update
$ brew reinstall imagemagick
$ git clone https://github.com/rossy/img2xterm.git
$ cd img2xterm && make && make install