Yeaaahh.
This commit is contained in:
parent
7d54769859
commit
7d9f263daa
|
@ -0,0 +1,26 @@
|
||||||
|
title: Cron
|
||||||
|
----
|
||||||
|
|
||||||
|
### Format
|
||||||
|
|
||||||
|
* Min Hour Day Month Weekday
|
||||||
|
|
||||||
|
|
||||||
|
### Format
|
||||||
|
|
||||||
|
* * * * * command to be executed
|
||||||
|
┬ ┬ ┬ ┬ ┬
|
||||||
|
│ │ │ │ │
|
||||||
|
│ │ │ │ │
|
||||||
|
│ │ │ │ └───── day of week (0 - 6) (0 or 6 are Sunday to Saturday, or use names)
|
||||||
|
│ │ │ └────────── month (1 - 12)
|
||||||
|
│ │ └─────────────── day of month (1 - 31)
|
||||||
|
│ └──────────────────── hour (0 - 23)
|
||||||
|
└───────────────────────── min (0 - 59)
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
0 * * * * every hour
|
||||||
|
*/15 * * * * every 15 mins
|
||||||
|
0 */2 * * * every 2 hours
|
||||||
|
0 0 0 * 0 every sunday midnight
|
4
curl.md
4
curl.md
|
@ -11,12 +11,14 @@ Options:
|
||||||
|
|
||||||
Data options:
|
Data options:
|
||||||
|
|
||||||
-d <data> # --data: HTTP post data
|
-d <data> # --data: HTTP post data, URL encoded (eg, status="Hello")
|
||||||
-G # --get: send -d data via get
|
-G # --get: send -d data via get
|
||||||
|
|
||||||
Headers:
|
Headers:
|
||||||
|
|
||||||
-A <str> # --user-agent
|
-A <str> # --user-agent
|
||||||
|
-b name=val # --cookie
|
||||||
|
-b FILE # --cookie
|
||||||
|
|
||||||
SSL:
|
SSL:
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
title: Express.js
|
||||||
|
---
|
||||||
|
|
||||||
|
### Settings
|
||||||
|
|
||||||
|
app.set('x', 'yyy')
|
||||||
|
app.get('x') //=> 'yyy'
|
||||||
|
|
||||||
|
app.enable('trust proxy')
|
||||||
|
app.disable('trust proxy')
|
||||||
|
|
||||||
|
app.enabled('trust proxy') //=> true
|
||||||
|
|
||||||
|
### Env
|
||||||
|
|
||||||
|
app.get('env')
|
||||||
|
|
||||||
|
### Config
|
||||||
|
|
||||||
|
app.configure('production', function() {
|
||||||
|
app.set...
|
||||||
|
});
|
||||||
|
|
||||||
|
### Wares
|
||||||
|
|
||||||
|
app.use(express.static(__dirname + '/public'));
|
||||||
|
app.use(express.logger());
|
||||||
|
|
||||||
|
### Helpers
|
||||||
|
|
||||||
|
app.locals({
|
||||||
|
title: "MyApp",
|
||||||
|
});
|
||||||
|
|
||||||
|
### Request
|
||||||
|
|
||||||
|
req.params
|
||||||
|
|
||||||
|
// GET /user/tj
|
||||||
|
req.params.name //=> "tj"
|
||||||
|
|
||||||
|
req.params[0]
|
||||||
|
|
||||||
|
// GET /search?q=tobi+ferret
|
||||||
|
req.query.q // => "tobi ferret"
|
||||||
|
|
||||||
|
req.cookies
|
||||||
|
|
||||||
|
req.accepted
|
||||||
|
[ { value: 'application/json', quality: 1, type: 'application', subtype: 'json' },
|
||||||
|
{ value: 'text/html', quality: 0.5, type: 'text',subtype: 'html' } ]
|
||||||
|
|
||||||
|
req.is('html')
|
||||||
|
req.is('text/html')
|
||||||
|
|
||||||
|
req.path
|
||||||
|
req.xhr
|
||||||
|
|
||||||
|
## Response
|
||||||
|
|
||||||
|
res.redirect('/')
|
||||||
|
res.redirect(301, '/')
|
||||||
|
|
||||||
|
res.set('Content-Type', 'text/html')
|
||||||
|
|
||||||
|
res.send('hi')
|
||||||
|
res.send(200, 'hi')
|
||||||
|
|
||||||
|
res.json({ a: 2 })
|
6
ios.md
6
ios.md
|
@ -2,9 +2,11 @@ Multiple Exchange accounts:
|
||||||
|
|
||||||
scp root@iphone.local:/private/var/mobile/Library/Preferences/com.apple.accountsettings.plist .
|
scp root@iphone.local:/private/var/mobile/Library/Preferences/com.apple.accountsettings.plist .
|
||||||
|
|
||||||
Winterboard themes:
|
Paths:
|
||||||
|
|
||||||
/Library/Themes
|
/Library/Themes # Winterboard themes
|
||||||
|
/User/Media/DCIM/100APPLE # Photos
|
||||||
|
/User/Media/Recordings # Voice recordings
|
||||||
|
|
||||||
Copy photos:
|
Copy photos:
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,12 @@
|
||||||
### Find files
|
### Find files
|
||||||
|
|
||||||
FILES = $(shell find images -name "*")
|
FILES = $(shell find images -name "*")
|
||||||
|
FILES = $(shell find test/*.js)
|
||||||
|
|
||||||
$(patsubst images/%, assets/%, $(shell find images -name "*"))
|
$(patsubst images/%, assets/%, $(shell find images -name "*"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Substitutions
|
### Substitutions
|
||||||
|
|
||||||
# Same
|
# Same
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
title: Package JSON
|
||||||
|
---
|
||||||
|
|
||||||
|
### Basic
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "expo",
|
||||||
|
"description": "",
|
||||||
|
"keywords": [""],
|
||||||
|
"author": "Rico Sta. Cruz <hi@ricostacruz.com>",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"engines": {"node": ">=0.8.0"},
|
||||||
|
}
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
"dependencies": {
|
||||||
|
"colors" : "*",
|
||||||
|
"flatiron" : "0.1.x",
|
||||||
|
"flatiron" : "~0.1.0",
|
||||||
|
"plates" : "https://github.com/:user/:project/tarball/:branch",
|
||||||
|
"stuff": "git://github.com/user/project.git#commit-ish"
|
||||||
|
},
|
||||||
|
"devDependencies": { ... },
|
||||||
|
|
||||||
|
### Scripts
|
||||||
|
|
||||||
|
"scripts": {
|
||||||
|
"start": "node ./bin/xxx", /* npm start */
|
||||||
|
"test": "vows --spec --isolate", /* npm test */
|
||||||
|
}
|
||||||
|
|
||||||
|
### Git
|
||||||
|
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/nodejitsu/http-server.git"
|
||||||
|
},
|
||||||
|
|
||||||
|
### Main entry point
|
||||||
|
|
||||||
|
"main": "index",
|
||||||
|
"main": "./lib/http-server",
|
||||||
|
|
||||||
|
### Bin
|
||||||
|
|
||||||
|
"bin": {
|
||||||
|
"command": "./bin/command"
|
||||||
|
},
|
||||||
|
|
||||||
|
### Misc
|
||||||
|
|
||||||
|
"private": true,
|
||||||
|
"preferGlobal": true,
|
||||||
|
"license": "MIT"
|
||||||
|
|
||||||
|
|
||||||
|
http://package.json.nodejitsu.com/
|
|
@ -0,0 +1,118 @@
|
||||||
|
title: NodeJS api
|
||||||
|
----
|
||||||
|
|
||||||
|
## Globals
|
||||||
|
|
||||||
|
__filename
|
||||||
|
__dirname
|
||||||
|
|
||||||
|
## [fs]
|
||||||
|
|
||||||
|
### Reading
|
||||||
|
|
||||||
|
fs.readFile('file.txt', function(err, data) { .. });
|
||||||
|
fs.readFile('file.txt', {encoding: 'utf-8'}, function(err, data) { .. });
|
||||||
|
|
||||||
|
### Writing
|
||||||
|
|
||||||
|
fs.writeFile('output.txt', function(err) { .. });
|
||||||
|
fs.appendFile('output.txt', function(err) { .. });
|
||||||
|
|
||||||
|
### Watch
|
||||||
|
|
||||||
|
fs.watch('dir OR file.txt', { persistent: true }, function(event, file) {
|
||||||
|
event; /* rename | change */
|
||||||
|
});
|
||||||
|
|
||||||
|
### Getting info
|
||||||
|
|
||||||
|
fs.exists('file.txt', function(exists /*bool*/) { ... });
|
||||||
|
|
||||||
|
fs.stat('file.txt', function(stats) {
|
||||||
|
stats.isFile();
|
||||||
|
stats.isDirectory();
|
||||||
|
stats.isSymbolicLink();
|
||||||
|
});
|
||||||
|
|
||||||
|
### File operations
|
||||||
|
|
||||||
|
fs.rename('old.txt', 'new.txt', function(){});
|
||||||
|
fs.chown('file.txt', uid, gid, function(){});
|
||||||
|
fs.symlink('src', 'dest', function(){});
|
||||||
|
fs.unlink('path', function(){});
|
||||||
|
fs.rmdir('path', function(){});
|
||||||
|
|
||||||
|
fs.readdir('path', function(err, files) { .. }); /* `files` = array of names */
|
||||||
|
|
||||||
|
### Path
|
||||||
|
|
||||||
|
fs.realpath('/etc/passwd', function(err, path) { /* "/private/etc/passwd" */ });
|
||||||
|
|
||||||
|
### Sync
|
||||||
|
|
||||||
|
data = fs.readFileSync('input.txt');
|
||||||
|
fs.writeFileSync('output.txt', data);
|
||||||
|
fs.appendFileSync('output.txt', data);
|
||||||
|
fs.existsSync('file.txt');
|
||||||
|
|
||||||
|
## [process]
|
||||||
|
|
||||||
|
### Streams
|
||||||
|
|
||||||
|
process.stdin.resume(); /* paused by default */
|
||||||
|
process.stdin.setEncoding('utf8');
|
||||||
|
|
||||||
|
process.stdin.on('data', function(chunk) { ... });
|
||||||
|
process.stdin.on('end', function() { ... });
|
||||||
|
|
||||||
|
process.stdout.write('...');
|
||||||
|
process.stderr.write('...');
|
||||||
|
|
||||||
|
### stuff
|
||||||
|
|
||||||
|
process.argv; //=> ['node', 'file.js', 'one', 'two']
|
||||||
|
process.env; //=> {TERM: 'screen-256color', SHELL: '/bin/bash', ...}
|
||||||
|
|
||||||
|
process.exit();
|
||||||
|
process.exit(1);
|
||||||
|
|
||||||
|
### Directories
|
||||||
|
|
||||||
|
process.cwd(); //=> "/tmp"
|
||||||
|
process.chdir('dir');
|
||||||
|
|
||||||
|
## [path]
|
||||||
|
|
||||||
|
fs.realpath('/etc/passwd', function(err, path) { /* "/private/etc/passwd" */ });
|
||||||
|
|
||||||
|
dir = path.join('etc', 'passwd');
|
||||||
|
dir = path.resolve('/etc', 'passwd', '..', 'var');
|
||||||
|
|
||||||
|
path.dirname('/etc/passwd') //=> "/etc"
|
||||||
|
path.basename('/etc/passwd') //=> "passwd"
|
||||||
|
path.basename('/etc/rc.d', '.d') //=> "rc"
|
||||||
|
|
||||||
|
### exec
|
||||||
|
|
||||||
|
var exec = require('child_process').exec,
|
||||||
|
|
||||||
|
var child = exec('cat *.js bad_file | wc -l',
|
||||||
|
function (error, stdout, stderr) {
|
||||||
|
console.log('stdout: ' + stdout);
|
||||||
|
console.log('stderr: ' + stderr);
|
||||||
|
if (error !== null) {
|
||||||
|
console.log('exec error: ' + error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
[all]: http://nodejs.org/api/all.html
|
||||||
|
[process]: http://nodejs.org/api/process.html
|
||||||
|
[fs]: http://nodejs.org/api/fs.html
|
||||||
|
|
||||||
|
## Snippets
|
||||||
|
|
||||||
|
info = require('../package.json')
|
||||||
|
info.version
|
||||||
|
|
||||||
|
|
||||||
|
process.stdout.write(util.inspect(objekt, false, Infinity, true) + '\n');
|
|
@ -1,5 +1,13 @@
|
||||||
|
### Console
|
||||||
|
|
||||||
|
$ psql
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
* Show tables: `\dt`
|
* Show tables: `\dt`
|
||||||
* Show databases: `\l`
|
* Show databases: `\l`
|
||||||
* Show columns of a table: `\d table` or `\d+ table`
|
* Show columns of a table: `\d table` or `\d+ table`
|
||||||
|
|
||||||
|
### Creating database
|
||||||
|
|
||||||
|
$ createdb databasename
|
||||||
|
|
|
@ -224,7 +224,7 @@ API
|
||||||
### Sorting
|
### Sorting
|
||||||
|
|
||||||
posts.order(:title)
|
posts.order(:title)
|
||||||
posts.order(:title).reverse
|
posts.order("title DESC")
|
||||||
|
|
||||||
### Mass updates
|
### Mass updates
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
in config/environments/development.rb:
|
||||||
|
|
||||||
|
# Source maps for Sass
|
||||||
|
config.sass.debug_info = true
|
||||||
|
config.sass.line_comments = false
|
|
@ -0,0 +1,60 @@
|
||||||
|
title: Sequelize
|
||||||
|
---
|
||||||
|
|
||||||
|
### API
|
||||||
|
|
||||||
|
sequelize.sync().done -> ...
|
||||||
|
|
||||||
|
### Models
|
||||||
|
|
||||||
|
Project = sequelize.define('Project', {
|
||||||
|
title: Sequelize.STRING,
|
||||||
|
description: Sequelize.TEXT,
|
||||||
|
myDate: { type: Sequelize.DATE, defaultValue: Sequelize.NOW },
|
||||||
|
title: { type: Sequelize.STRING, allowNull: false },
|
||||||
|
id: { type: Sequelize.INTEGER, autoIncrement: true, primaryKey: true },
|
||||||
|
}, {
|
||||||
|
classMethods: { ... },
|
||||||
|
instanceMethods: { ... }
|
||||||
|
});
|
||||||
|
|
||||||
|
Project.hasMany(Task)
|
||||||
|
|
||||||
|
### Finders
|
||||||
|
|
||||||
|
Project.find(123).success (project) ->
|
||||||
|
|
||||||
|
Project.find({ where: {title: 'Hello'} })
|
||||||
|
Project.find({ where: {id: [1,3,4]} })
|
||||||
|
Project.find({ where: ["id > ?", 25] })
|
||||||
|
|
||||||
|
Project.find(
|
||||||
|
where: {title: 'a'}
|
||||||
|
attributes: ['id', ['name', 'title']]
|
||||||
|
)
|
||||||
|
|
||||||
|
.findOrCreate(...)
|
||||||
|
|
||||||
|
.findAll
|
||||||
|
.findAll({ where: ... })
|
||||||
|
.findAll({ order: 'title DESC' })
|
||||||
|
.findAll({ limit: 10 })
|
||||||
|
.findAll({ offset: 10, limit: 2 })
|
||||||
|
|
||||||
|
.count()
|
||||||
|
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
|
item = Project.build({ ... })
|
||||||
|
|
||||||
|
item.title = '...'
|
||||||
|
|
||||||
|
item.save().success (item) ->
|
||||||
|
|
||||||
|
item.updateAttributes({ title: '...' })
|
||||||
|
|
||||||
|
item.destroy().success ->
|
||||||
|
|
||||||
|
item.values
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
title: Sinon
|
||||||
|
---
|
||||||
|
|
||||||
|
### Spy
|
||||||
|
|
||||||
|
var fn = sinon.spy();
|
||||||
|
fn();
|
||||||
|
fn.calledOnce == true
|
||||||
|
fn.calledCount == 1
|
||||||
|
|
||||||
|
### Spy something
|
||||||
|
|
||||||
|
sinon.spy($, 'ajax')
|
||||||
|
|
||||||
|
### Stub
|
||||||
|
|
||||||
|
var fn = sinon.stub().returns(42);
|
||||||
|
fn() == 42
|
||||||
|
|
||||||
|
fn.withArgs(42).returns(1);
|
||||||
|
fn.withArgs(43).throws("TypeError");
|
||||||
|
stub.returnsArg(0); // Return 1st argument
|
||||||
|
stub.callsArg(0);
|
||||||
|
|
||||||
|
### Stub something
|
||||||
|
|
||||||
|
sinon.stub($, 'ajax');
|
||||||
|
$.ajax.calledWithMatch({ url: '/x' });
|
||||||
|
$.ajax.restore();
|
||||||
|
|
||||||
|
sinon.stub($, 'ajax', function() { return 'x' });
|
||||||
|
|
||||||
|
### Fake server
|
||||||
|
|
||||||
|
server = sinon.fakeServer.create();
|
||||||
|
|
||||||
|
$.get('/file.json', ...);
|
||||||
|
server.requests[0].respond(
|
||||||
|
200,
|
||||||
|
{ "Content-Type": "application/json" },
|
||||||
|
JSON.stringify([{ id: 1, text: "Provide examples", done: true }])
|
||||||
|
);
|
||||||
|
|
||||||
|
server.restore();
|
||||||
|
|
||||||
|
### Fake XHR
|
||||||
|
|
||||||
|
xhr = sinon.useFakeXMLHttpRequest();
|
||||||
|
xhr.restore();
|
|
@ -0,0 +1,53 @@
|
||||||
|
title: Travis (.travis.yml)
|
||||||
|
---
|
||||||
|
|
||||||
|
### Node
|
||||||
|
|
||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- "0.10"
|
||||||
|
|
||||||
|
* Provides: 0.10, 0.8, 0.6, 0.11 (latest dev)
|
||||||
|
* Defaults install to `npm install`
|
||||||
|
* Defaults test to `npm test`
|
||||||
|
|
||||||
|
### Ruby
|
||||||
|
|
||||||
|
language: ruby
|
||||||
|
rvm:
|
||||||
|
- 1.9.3
|
||||||
|
- 1.8.7
|
||||||
|
- rbx-19mode
|
||||||
|
- jruby-19mode
|
||||||
|
- jruby-18mode
|
||||||
|
|
||||||
|
* * Defaults install to `bundle install`
|
||||||
|
* Defaults test to `rake`
|
||||||
|
|
||||||
|
### Branches
|
||||||
|
|
||||||
|
branches:
|
||||||
|
except: [".."]
|
||||||
|
only: ["master"]
|
||||||
|
|
||||||
|
### Environment vars
|
||||||
|
|
||||||
|
env:
|
||||||
|
- "rack=master"
|
||||||
|
- "rack=1.3.4"
|
||||||
|
|
||||||
|
### Custom config
|
||||||
|
|
||||||
|
script: make test
|
||||||
|
before_script: make pretest
|
||||||
|
after_script: make clean
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- make pretest1
|
||||||
|
- make pretest2
|
||||||
|
|
||||||
|
### References
|
||||||
|
|
||||||
|
* http://about.travis-ci.org/docs/user/build-configuration/
|
||||||
|
* http://about.travis-ci.org/docs/user/languages/javascript-with-nodejs/
|
||||||
|
* http://about.travis-ci.org/docs/user/languages/ruby/
|
Loading…
Reference in New Issue