From 07b75507184c8d03a2891883a50fb8332b7eb1ff Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Thu, 29 Aug 2013 00:04:46 +0800 Subject: [PATCH] Updates. --- bash.md | 12 ++++++++ heroku.md | 82 +++++++++++++++++++++++++++++++++++++++++++------- shelljs.md | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+), 10 deletions(-) create mode 100644 shelljs.md diff --git a/bash.md b/bash.md index 046387fe6..a719417a6 100644 --- a/bash.md +++ b/bash.md @@ -188,6 +188,18 @@ or set -o errtrace trap traperr ERR +### Case/switch + + case $1 in + start | up) + vagrant up + ;; + + *) + echo "Usage: $0 {start|stop|ssh}" + ;; + esac + References ---------- diff --git a/heroku.md b/heroku.md index 1ba9414d7..7d061421c 100644 --- a/heroku.md +++ b/heroku.md @@ -1,14 +1,69 @@ - -## Create an app +## `create` - Create an app heroku create sushi -## Custom domains +## `sharing` - Collaboration - heroku addon:add custom_domains + # Manage collaborators + heroku sharing # List + heroku sharing:add me@xy.com + heroku sharing:remove me@xy.com - heroku domains:add example.com - heroku domains:add www.example.com + # Transfer to another owner + heroku sharing:transfer new@owner.com + +## `pg` - Postgresql + + # Start a database + heroku addons:add heroku-postgresql + heroku pg:promote HEROKU_POSTGRESQL_PURPLE_URL + + # Enable backups + heroku addons:add pgbackups:auto-month + +## `ps` - Managing processes + + heroku ps # list + heroku ps:scale web=1 # spawn more dynos + +## `run` - Running + + heroku run bash + heroku run console # Rails console + heroku run rake assets:precompile + +## `config` - Environment var configuration + + heroku config # List + heroku config -s # List in shell format + + heroku config:get KEY + + heroku config:set KEY=val + heroku config:set KEY1=val KEY2=val ... + + heroku config:unset KEY1 + +## `apps` - Applications + + heroku apps # list + heroku apps:create [NAME] + heroku apps:destroy + heroku apps:info + heroku apps:open # open in browser + heroku apps:rename NEWNAME + +## `domains` - Custom domains + + heroku addon:add custom_domains + + # Add both! + heroku domains:add example.com + heroku domains:add www.example.com + + # Removing: + heroku domains:clear + heroku domains:remove example.com ## DNS records @@ -30,15 +85,22 @@ ## htpasswd (for PHP apps) -Create an .htaccess file in the webroot: +Create an `.htaccess` file in the webroot: AuthUserFile /app/www/.htpasswd AuthType Basic AuthName "Restricted Access" Require valid-user -Create a .htpasswd file: +Create a `.htpasswd` file: - htpasswd -c .htpasswd [username] + $ htpasswd -c .htpasswd [username] -https://gist.github.com/3316425 +See https://gist.github.com/3316425 + +## References: + + * https://addons.heroku.com/ + * https://devcenter.heroku.com/ + * https://devcenter.heroku.com/articles/custom-domains + * https://devcenter.heroku.com/articles/heroku-postgresql diff --git a/shelljs.md b/shelljs.md new file mode 100644 index 000000000..b49a1499b --- /dev/null +++ b/shelljs.md @@ -0,0 +1,87 @@ +### Require + + require 'shelljs/global' + +### Paths + + cd 'dir' + + mkdir 'dir' + mkdir '-p', 'dir' + +### File manip + + cp 'src', 'dest' + cp '-rf', 'src', 'dest' + + rm 'file' + rm '-rf', 'file' + + mv 'src', 'dest' + mv ['src1','src2'], 'dest' + + chmod '644', 'file' + chmod 755, 'file' + chmod 'u+x', 'file' + +### Tests + + test '-b', 'path' # block device + test '-d', 'path' # dir + test '-e', 'path' # exists + test '-f', 'path' # file + test '-L', 'path' # symlink + +### Cat and output + + src = cat('file*.txt') + + "hello".to('output.txt'); + "hello".toEnd('append.txt'); + + cat('input.txt').to('output.txt'); + +### Utils + + which('x') + pwd() + + echo 'hi' + + exec('node --version').code + exec('node --version').output + exec('node --version', {silent:true}).output + + exec 'node --version', (code, output) -> + echo "exit code #{code}" + + tempdir() + + error() # null if no error + +### Make + + require 'shelljs/make' + + target.all = -> + target.bundle() + target.docs() + + target.bundle = -> + cd __dirname + mkdir 'build' + cd 'lib' + (cat '*.js').to '../build/output.js' + + target.docs = -> + cd __dirname + mkdir 'docs' + cd 'lib' + for file in ls '*.js' + text = grep '//@', file # extract special comments + text.replace '//@', '' # remove comment tags + text.to 'docs/my_docs.md' + +### References + + * https://github.com/arturadib/shelljs