"string to check".to_enum(:scan, /\s/).map { Regexp.last_match }
for i in $(seq 1 255); do echo -n $(printf '\\x%02x' $i); done
( set -o posix ; set )
for i in PATTERN; do echo mv $i ${i/old/new}; done
!$
-
ctrl + a
- start of line (home) -
ctrl + w
- delete back to whitespace -
ctrl + x, e
- open editor -
(set -o posix; set)
list all shell and env vars (no functions) -
find src/ -name *cs | xargs grep --no-filename using | sort | uniq
get all the using statements in the cs files -
reset; stty sane; tput rs1; clear; echo -e "\033c"
- unscrew corrupted terminal -
openssl aes-256-cbc -md sha256 -e -in file -out file-cipher -k $KEY
- encrypt a file -
openssl aes-256-cbc -md sha256 -d -in file-cipher -k ${KEY} >> file
- decrypt
$ grep -irl ccbResources/ccb . | xargs -I[] sed -i '' "s/ccbResources\/ccb/Resources\//g" []
sed -n '/start/,/end/p;/end/q' $filename
git tag -d <tag name> && git push origin :refs/tags/<tag name>
[alias]
s = status
cma = commit -am
cm = commit -m
cont = rebase --continue
dumbass = commit --amend
forget = update-index --assume-unchanged
unforget = update-index --no-assume-unchanged
root = rev-parse --show-toplevel
lg = "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"
ignored = ls-files -o -i --exclude-standard
fetch-pr = "!f() { git fetch $1 refs/pull/$2/head:pr-$2; }; f"
awk -F ',' 'BEGIN {OFS=","} { if( $1 == "COOL_CONDITION") print }' csv_file.csv
- osx
dd if=/dev/zero of=output.dat bs=1024000 count=1
- change count to number of megabytes
date +'%d %B %Y'
get "30 September 2015" or w/e as output
:Gdiff
:diffget
:Gstatus
-
- stage / unstage (reset) fileCTRL+N
- next file
$('img[src$=".jpg"]')
- get all img tags with src attribute ending in '.jpg' ($=
is 'attribute ends with' )
adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n <packagename>/<java classname" --es "referrer" "referrer=value&stuff=url"
adb shell setprop debug.checkjni 0
- change 1 or 0 to activate/deactivate
adb shell settings put global stay_on_while_plugged_in 3
keytool -genkey -v -keystore keystore.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
xcrun simctl addmedia booted ./qrcode.png
- upload qrcode to camera roll
-
generate self signed ssl certificate
openssl req -newkey rsa:2048 -nodes -sha256 -keyout keyname.key -x509 -days 3650 -out certname.crt -subj "/C=US/ST=NewYork/L=NewYork/O=IT/CN=*.wildcard.domain" -config <(cat /System/Library/OpenSSL/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:*.wildcard.domain'))
-
then some diffie hellman
openssl dhparam -out dhparam.pem 2048
-
ssh port forwarding to localhost
ssh -L REMOTE_PORT:127.0.0.1:LOCAL_PORT username@remote.host
-
symbolicate ios crash
DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer symbolicatecrash -d <path to dsym> -o <symbolicated>.crash <original>.crash
- approximate drawing a circle
int inc = 5;
for (float ang = 0; ang < 360; ang +=inc)
float rad = radians(ang);
x = centX + (radius * cos(rad));
y = centY + (radius * sin(rad));
point(x,y);
}
(change radius every step for spiral)
- split something large into smaller
convert -crop widthxheight source.png icon_%d.png
- create screen
ctrl+a, c
- next screen
ctrl+a, n
- detach screen
ctrl+a, d
- kill everything
ctrl+a, \
- apply a git patch to a different tree
git diff HEAD^ [file or whatever to get the diff] >> [patchfilename] && patch [location to apply patch] [patchfile]
- generate a small icon for text
function svgForText(txt){
return '<svg width="24" height="24" ' +
'xmlns="http://www.w3.org/2000/svg">' +
'<rect stroke="white" fill="#640012" x="1" y="1" width="22" ' +
'height="22" /><text x="12" y="18" font-size="12pt" ' +
'font-family="Arial" font-weight="bold" text-anchor="middle" ' +
'fill="white">'+txt+'</text></svg>';
}
curl -s http://support-sp.apple.com/sp/product?cc=`system_profiler SPHardwareDataType | awk '/Serial/ {print $4}' | cut -c 9-` | sed 's|.*<configCode>\(.*\)</configCode>.*|\1|'
otool -tV <lib path> -p "-[ClassName methodName]"
netstat -tulpn
- osx
sudo lsof -PiTCP -sTCP:LISTEN