From accde21033e28a18ed422e641ed6af9e651da896 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Thu, 3 Jan 2013 17:53:53 +0800 Subject: [PATCH] Updates. --- command_line.md | 71 +++++++++++++++++++++++++++++++++-- do.md | 91 +++++++++++++++++++++++++++++++++++++++++++++ ec2.md | 52 ++++++++++++++++++++++++++ html.md | 99 ++++++++++++++++++++++++++++++++++++++++++------- znc.md | 18 +++++++++ 5 files changed, 314 insertions(+), 17 deletions(-) create mode 100644 do.md create mode 100644 ec2.md create mode 100644 znc.md diff --git a/command_line.md b/command_line.md index 6297e7391..6c1efedab 100644 --- a/command_line.md +++ b/command_line.md @@ -1,7 +1,7 @@ title: Command line stuff --- -### List (ls) +## List (ls) Usage: @@ -35,7 +35,7 @@ Sorting: -h Human-readable size (3k) -### Find (find) +## Find (find) Usage: @@ -78,7 +78,72 @@ Examples: find . -newerBt "24 hours ago" -### Search-and-replace in all files +## Tail + +Usage: + + tail [-F | -f | -r] [-bN | -cN | -nN] [file ...] + +Modes: + + -f # follow + -F # follow by filename (accounts for log rotation) + -r # Reverse order + +Options: + + -bN # N*512 bytes + -cN # N bytes + -nN # N lines + + +N # Start from line N + +## Sudo + +Listing: + + -l # List allowed commands + +Options: + + -A # Use $SUDO_ASKPASS + -b # Run in background + -E # Preserve environment + -H # use target's $HOME + -n # Don't prompt for password + -P # Preserve group vector + -S # Read password from stdin + +File descriptors: + + -C fd # Close all open file descriptors + +Prompt: + + -p prompt # Custom prompt (-p "%p password:") + +Interactive: + + -i [cmd] # Interactive shell without variables + -s [cmd] # Interactive shell + + -u user # run as this user + -g group # run as this group + +Timestamp: + + -v # revalidate timestamp for 5 mins + -k # invalidate timestamp + -K # just like -k + +## wc (Word count) + + -c # Bytes + -l # Lines + -m # Characters (incl multi-byte) + -w # Words + +## Search-and-replace in all files perl -p -i -e 's/hello/HELLO/g' **/* diff --git a/do.md b/do.md new file mode 100644 index 000000000..b24bd6a3f --- /dev/null +++ b/do.md @@ -0,0 +1,91 @@ +title: Do gem +---- + + * [DAddYE/do](https://github.com/DAddYE/do) + +### Connection + + server = DO::Server.new('srv1', 'srv1.domain.local', 'root', :key => + %w[srv1.pem] + +### Run + server.run 'uname' + # root@srv1 ~ # uname + # Linux + + server.run 'uname', '-a' + # root@srv1 ~ # uname -a + # Linux srv1.lipsiasoft.net 2.6.18-194.32.1.el5 x86_64 x86_64 x86_64 GNU/Linux + + server.run 'mysqladmin -u root -p password "oldone"', 'newpassword' + # root@srv1 ~ # mysqladmin -u root -p password 'oldone' + # Enter password: oldone + # mysqladmin: connect to server at 'localhost' failed + # error: 'Access denied for user 'root'@'localhost' (using password: YES)' + +### Files + + server.exist?('~/.ssh') + # root@srv1 ~ # test -e ~/.ssh && echo True + # => true + + server.read('/etc/redhat-release') + # root@srv1 ~ # cat /etc/redhat-release + # => "CentOS release 5.5 (Final)" + +### Upload/download + + server.upload '/tmp/file', '/tmp/foo' + # root@srv1 ~ # upload from '/tmp/file' to '/tmp/foo' + + server.download '/tmp/foo', '/tmp/file2' + # root@srv1 ~ # download from '/tmp/foo' to '/tmp/file2' + +### Replace + + server.replace :all, 'new content', '/tmp/file' + # root@srv1 ~ # replace all in '/tmp/foo' + + server.read('/tmp/foo') + # root@srv1 ~ # cat /tmp/foo + # => "new content" + +### Replace via regex + + server.replace /content$/, 'changed content', '/tmp/foo' + # root@srv1 ~ # replace /content$/ in '/tmp/foo' + + server.read('/tmp/foo') + # root@srv1 ~ # cat /tmp/foo + # => "new changed content" + +### Append + + server.append('appended', '/tmp/foo') + # root@srv1 ~ # append to 'bottom' in '/tmp/foo' + + server.read('/tmp/foo') + # root@srv1 ~ # cat /tmp/foo + # => "new changed contentappended" + +### Append to top + + server.append('---', '/tmp/foo', :top) + # root@srv1 ~ # append to 'top' in '/tmp/foo' + + server.read('/tmp/foo') + # root@srv1 ~ # cat /tmp/foo + # => "---new changed contentappended" + +### Prompt + + server.ask "Please choose" + # root@srv1 ~ # Please choose: foo + # => "foo" + + server.yes? "Do you want to proceed" + # root@srv1 ~ # Do you want to proceed? (y/n): y + # => 0 + + server.wait + # Press ENTER to continue... diff --git a/ec2.md b/ec2.md new file mode 100644 index 000000000..d99ce6855 --- /dev/null +++ b/ec2.md @@ -0,0 +1,52 @@ +title: EC2 API tools +--- + +### Install + + $ sudo apt-get install ec2-api-tools ec2-ami-tools # Ubuntu + $ brew install ec2-api-tools ec2-ami-tools # OSX/Homebrew + +### Key pair + +To use public images (AMI's), you need an SSH keypair from EC2. + + $ ec2-add-keypair my-keypair > ~/.ec2/my-keypair.pem + $ chmod 600 ec2-keypair.pem + +### Start an instance + + # Show images (AMI's) owned by amazon, or me + $ ec2-describe-images -o self -o amazon + + # Start an instance using a given AMI image + $ ec2-run-instances ami-xxxxxx -k ec2-keypair + + # Open up ports (in the 'default' security group) + $ ec2-authorize default -p 22 + $ ec2-authorize default -p 80 + + # Now SSH to it + $ ssh -i ~/.ec2/my-keypair.pem root@ec2-xxx.amazonaws.com + +### Management + + # Show running + $ ec2-describe-instances + + # Kill an instance + $ ec2-terminate-instances i-yourinstance + +### Misc + + # Create a security group + $ ec2-add-group group_name -d "Description" + +### Ubuntu images + + * [Ubuntu EC2 AMI locator](http://cloud-images.ubuntu.com/locator/ec2/) + +### Change certificates + + EC2_CERT_PATH="$HOME/.ec2" + export EC2_PRIVATE_KEY="$(/bin/ls $EC2_CERT_PATH/pk-*.pem | /usr/bin/head -1)" + export EC2_CERT="$(/bin/ls $EC2_CERT_PATH/cert-*.pem | /usr/bin/head -1)" diff --git a/html.md b/html.md index 2aedc5a70..40c12717f 100644 --- a/html.md +++ b/html.md @@ -1,6 +1,73 @@ title: HTML --- +### Head stuff + + + + + +### iPhone viewport + + + + + +### Default OpenGraph meta tags + + + + + + + + + +### Webfonts + + + + // {typekit{id:"..."}} + // {google:{families:['Exo:400']}} + +### Google Analytics + + + +### FB/Twitter + +
+ + + +### HTML5 Shiv for IE8 + + + +### H5BP HTML tag (IE8 and IE9 only) + + + + +### Touch icons + + apple-touch-icon-precomposed.png + apple-touch-icon-57x57-precomposed.png + apple-touch-icon-72x72-precomposed.png + apple-touch-icon-114x114-precomposed.png + apple-touch-icon-144x144-precomposed.png + +### Icons + +Only do this if you're not placing the site in the root! + + + + + + + + ### H5BP HTML tag @@ -11,25 +78,29 @@ title: HTML ### IE conditionals - - Not IE - -### iPhone viewport - - + + + + + ### Google jQuery - + -### Chrome frame +### Unsupported message diff --git a/znc.md b/znc.md new file mode 100644 index 000000000..8d44b2e25 --- /dev/null +++ b/znc.md @@ -0,0 +1,18 @@ +title: ZNC bouncer +--- + +## Away + + /msg *status loadmod away + /msg *away away + /msg *away back + /msg *away show #=> Show messages + /msg *away delete all + +## Watch + + /msg *status loadmod watch + /msg *watch list + /msg *watch add * *watch *rico* + /msg *watch add * *watch *%nick%* +