Skip to content

Instantly share code, notes, and snippets.

View jeremyjs's full-sized avatar

Jeremy Meyer jeremyjs

  • San Francisco, CA
View GitHub Profile
task :add_submodule, [:a0, :a1] do |t, args|
install_path = "janus/#{args[:a1]}"
puts "*installing #{args[:a0]} to #{install_path}"
`git submodule add #{args[:a0]} #{install_path}`
end
# change to the 'myfolder' directory within the current directory
$ cd myfolder/
$ cd ./myfolder
$ cd myfolder
$ cd ../myfolder_parent/myfolder
# change to the 'usr' directory within the root directory
$ cd /usr/
$ cd /usr
# view environment variables
$ printenv
PATH=/usr/local/heroku/bin:/usr/local/heroku/bin:/Users/jmeyer1/.rbenv/bin:/Users/jmeyer1/code/8b/bin:/Users/jmeyer1/.rbenv/shims:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
TMPDIR=/var/folders/wz/v_ty7wz108v3tz90gg627nt40000gp/T/
SHELL=/bin/zsh
HOME=/Users/jmeyer1
USER=jmeyer1
LOGNAME=jmeyer1
SSH_AUTH_SOCK=/tmp/launch-E2mZnk/Listeners
Apple_PubSub_Socket_Render=/tmp/launch-GhVrOe/Render
$ touch jmeyer.txt
$ scp jmeyer.txt [email protected]:/tmp
The authenticity of host 'vor.dev.cashnetusa.com (10.10.212.130)' can't be established.
RSA key fingerprint is 12:05:3d:8c:37:bf:a6:97:4e:e4:d8:ee:33:d1:19:15.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'vor.dev.cashnetusa.com,10.10.212.130' (RSA) to the list of known hosts.
[email protected]'s password:
jmeyer.txt 100% 0 0.0KB/s 00:00
$ rm jmeyer.txt
# Create file
$ touch /tmp/file.tmp
$ l /tmp/file.tmp
-rw-r--r-- 1 jmeyer1 wheel 0B Jun 16 15:59 /tmp/file.tmp
# Change owner to root
$ sudo chown root /tmp/file.tmp
$ l /tmp/file.tmp
-rw-r--r-- 1 root wheel 0B Jun 16 15:59 /tmp/file.tmp
# why is sudo necessary?
to run commands that affect the entire system, or exist outside of any
particular user's home directory
# why is sudo dangerous?
Using sudo, it's possible to delete vital files, directories, or even your
entire system. e.g. "sudo rm -rf /" Don't try this at home. Essentially any
command which is non-reversible is potentially dangerous.
# check current free space
$ df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk0s2 233Gi 74Gi 158Gi 32% 19571865 41464807 32% /
devfs 221Ki 221Ki 0Bi 100% 767 0 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
/dev/disk1s2 8.0Mi 1.9Mi 6.1Mi 24% 481 1557 24% /Volumes/Adobe Reader Installer
/dev/disk2s2 3.7Mi 1.9Mi 1.9Mi 50% 477 480 50% /Volumes/SDL
/dev/disk3s2 11Mi 7.8Mi 2.9Mi 74% 1993 730 73% /Volumes/SDL2_mixer
$ ruby -e 'sleep 1 while true' &
[1] 80604
$ fg %1
[1] + 80604 running ruby -e 'sleep 1 while true'
^Z
[1] + 80604 suspended ruby -e 'sleep 1 while true'
$ ps
PID TTY TIME CMD
# replace characters in a string
s = "string"
puts s.tr('i', 'o')
puts s.tr('string', 'Heroku')
puts s.tr_s('ri', 'u')