This commit is contained in:
Rico Sta. Cruz 2013-01-03 17:53:53 +08:00
parent 19e171c2a3
commit accde21033
5 changed files with 314 additions and 17 deletions

View File

@ -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' **/*

91
do.md Normal file
View File

@ -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...

52
ec2.md Normal file
View File

@ -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)"

93
html.md
View File

@ -1,6 +1,73 @@
title: HTML
---
### Head stuff
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<link rel="shortcut icon" type="image/png" href="/favicon.png">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
### iPhone viewport
<meta name="viewport" content="initial-scale=1.0; maximum-scale=1.0">
<meta name="viewport" content="width=device-width">
<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/> <!-- full example -->
### Default OpenGraph meta tags
<meta content="..." name="description">
<meta content="..." property="og:description">
<meta content="http://.../preview.jpg" property="og:image">
<meta content="Hello There" property="og:title">
<meta content="Hello There" property="og:site_name">
<meta content="hellothere" property="fb:admins">
<meta content="website" property="og:type">
### Webfonts
<script>WebFontConfig={ },function(a,b){var c=a.createElement(b);c.src="//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js",c.async=1;var d=a.getElementsByTagName(b)[0];d.parentNode.insertBefore(c,d)}(document,"script")</script>
// {typekit{id:"..."}}
// {google:{families:['Exo:400']}}
### Google Analytics
<script>location.hostname.match(/helloworld\.com/)&&(_gaq=[["_setAccount","UA-XXXXX-1"],["_trackPageview"]],function(a,b){var c=a.createElement(b),d=a.getElementsByTagName(b)[0];c.async=1,c.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js",d.parentNode.insertBefore(c,d)}(document,"script"))</script>
### FB/Twitter
<div id="fb-root"></div><script>fbAsyncInit=function(){FB.init({"appId":"___APPIDGOESHERE___","status":true,"cookie":true,"xfbml":true})};!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.async=1;js.src='//connect.facebook.net/en_US/all.js';fjs.parentNode.insertBefore(js,fjs);}}(document,'script','facebook-jssdk');</script>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.async=1;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
### HTML5 Shiv for IE8
<!--[if lte IE 8]><script src='//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js'></script><![endif]-->
### H5BP HTML tag (IE8 and IE9 only)
<!--[if lte IE 8]><html class="ie8"><![endif]--><!--[if IE 9]><html class="ie9"><![endif]--><!--[if gt IE 9]><!-->
<html><!--<![endif]-->
### 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!
<link rel="shortcut icon" type="image/png" href="favicon.png">
<link href="apple-touch-icon-precomposed.png" rel="apple-touch-icon">
<link href="apple-touch-icon-57x57-precomposed.png" size="57x57" rel="apple-touch-icon">
<link href="apple-touch-icon-72x72-precomposed.png" size="72x72" rel="apple-touch-icon">
<link href="apple-touch-icon-114x114-precomposed.png" size="114x114" rel="apple-touch-icon">
<link href="apple-touch-icon-144x144-precomposed.png" size="144x144" rel="apple-touch-icon">
### H5BP HTML tag
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
@ -11,25 +78,29 @@ title: HTML
### IE conditionals
<!--[if IE]> I'm IE <![endif]-->
<!--[if !IE]> --> Not IE <!-- <![endif]-->
### iPhone viewport
<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
### Google jQuery
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
### Chrome frame
### Unsupported message
<!--[if lt IE 8]>
<div class="upgrade-banner">
You are using an <strong>outdated</strong> browser. Please <a
<div class="unsupported-browser">
<strong>
You are using an outdated browser.
</strong>
<span>
Please <a class="upgrade-browser"
href="http://browsehappy.com/">
upgrade your browser</a> or <a
upgrade your browser</a> or <a class="chrome-frame"
href="http://www.google.com/chromeframe/?redirect=true">activate Google
Chrome Frame</a> to improve your experience.
</span>
</div>
<![endif]-->

18
znc.md Normal file
View File

@ -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%*