github @username idettman

IntelliJ find and replace Regex

Reformat the following time value "[2:15 PM]" by removing the brackets Find \[(.*)\] Replace $1 Add two spaces to the end of every line, to create line-break in markdown Find [\r\n] Replace \n Add backticks around values surrounded by parenthesis Find \((.*)\) Replace `\($1\)`

Bash find process by port and kill

Find processes using port 9999 lsof -i :9999 Kill using the PID from lsof kill -9 <PID>

Bash query app information using the Launch Services

You can query app information using the Launch Services database to dump a list of all registered apps, then grep for the one you want (in this case Google Chrome), for example: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep -i "google chrome" Gives me the output: path: /Applications/Google Chrome.app/ executable: Contents/MacOS/Google Chrome path: /Applications/Google Chrome.app/Contents/Versions/27.0.1453.116/Google Chrome Helper.app/ executable: Contents/MacOS/Google Chrome Helper

Bash Type Command

type: type [-afptP] name [name …] For each name indicate how it would be interpreted if used as a command name -t returns one of alias, keyword, function, builtin, file, '' if name is an alias, shell reserved word, shell function, shell builtin, disk file, or unfound -p returns the name of the disk file that would be executed or nothing if type -t NAME would not return file -P forces a path search for each name, even if it is an alias, builtin, function returns the name of the disk file that would be executed -a returns all of the places that contain an executable named file that includes aliases, builtins, functions, if the -p flag is not also used -f suppresses shell function lookup Example: get file path command: type -P node result: /usr/local/bin/node Example: get file type command: type -t node result: file command: type -t source result: builtin typeset: typeset [-afFirtx] [-p] name[=value]

Bash Various

wget brew install wget wget http://google.com flush osx DNS cache sudo killall -HUP mDNSResponder curl curl --proxy http://proxy.iiiii.com:80 http://matrix.cccmmmtts.net:8081/nexus/content/groups/public/spy/spymemcached/2.6/ curl -O http://appldnld.apple.com/iTunes11/091-6058.20130605.Cw321/iTunes11.0.4.dmg nslookup nslookup matrix.comcastnets.net touch touch filename.ext show command history history show current processes top show external IP address curl ipecho.net/plain; echo show network IP address ipconfig getifaddr en0 run the last command again !! if you forgot sudo on last command sudo !! start a simple server in any folder python -m SimpleHTTPServer 8000 view file system usage sudo fs_usage copy large folder/file data ditto -V /old/work/ /new/work/

User/Group

chown sudo chown -R username:group directory (change ownership for both user and group recursively) chown reference usermod sudo usermod -a -G groupName userName (add a user to a group) usermod post su su reference

Directory

ls -a do not ignore files starting with "." -l long listing format -lt show and sort by ctime (time of last modification) -ltu show and sort by access time -g long listing without owner displayed -gG long listing without owner or group displayed -h human readable file-size

Symbolic Link

ln [options] (target file) [link name] ln -sv /media/fileserver/anotherfile.ods /home/user/anotherfile.ods s option creates a symbolic link, if omitted a hard link will be created. ln will show what it's doing. You could also cd to target's directory first: cd /media/fileserver ln -sv anotherfile.ods /home/user/anotherfile.ods Or cd to destination directory: cd /home/user/ ln -sv /media/fileserver/anotherfile.ods If you omit the link name, target's name is used. The above command creates a link to /media/fileserver/anotherfile.ods in /home/user/anotherfile.ods