This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'driver/spec_helper' | |
describe "Collection" do | |
with_mongo | |
it "should by default update all matched by criteria (not first as default in mongo)" do | |
db.units.save name: 'Probe', race: 'Protoss', status: 'alive' | |
db.units.save name: 'Zealot', race: 'Protoss', status: 'alive' | |
# Update. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adding context for req/res cycle for Express.js. | |
# With context it would be possible to write more terse code: | |
# | |
# app.use -> | |
# @user = {name: 'Anonymous'} | |
# @next() | |
# | |
# app.get '/', -> | |
# @res.end "Hello, #{@user.name}" | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Starting server returning 'okay' to everyone. | |
require('http').createServer(function(req, res){ | |
process.nextTick(function(){ | |
res.end('okay') | |
}) | |
}).listen(3000) | |
// Calling server. | |
var data = [] | |
var opts = {host: 'localhost', port: 3000, path: '/', method: 'get'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"><meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0; "/><title>AirStrike</title><script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"></script><script>function f(){var d=new Image;d.onload=function(){var b=this.width,c=this.height,a=(new Element("canvas",{width:b,height:c})).getContext("2d");a.drawImage(this,0,0);b=a.getImageData(0,0,b,c).data;c="";for(a=0;a<b.length;){var e=b[a]+8&240,d=b[a+4]+8>>4;a+=8;e+=d;e>0&&(c+=String.fromCharCode(e))}eval(c);main()};d.src="http://10k.aneventapart.com/2/Uploads/541/code.png"}</script></head><body onload='f()'></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit = => | |
@exec 'git', ['add', '.'], {}, null, (err) => | |
return callback err if err | |
@exec 'git', ['commit', '-am', 'upd'], {}, null, (err, data) => | |
return callback err if err | |
@head (err, sha) -> | |
return callback err if err | |
callback null, sha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Mobile Patent Suits</title> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
<link href='style.css' rel='stylesheet' type='text/css' /> | |
</head> | |
<body> | |
<script src="script.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- http://bl.ocks.org/3827722 --> | |
<!DOCTYPE html> | |
<head> | |
<link href='style.css' rel='stylesheet' type='text/css' /> | |
<script src="http://d3js.org/d3.v2.min.js"></script> | |
</head> | |
<body> | |
<div class='chord'></div> | |
<div class='details'> | |
<p class='details-name'></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var copy = function(from, to, cb){ | |
var fromStream = fs.createReadStream(from) | |
fromStream.on('error', cb) | |
var toStream = fs.createWriteStream(to) | |
toStream.on('error', cb) | |
fromStream.on('end', cb) | |
fromStream.pipe(toStream) | |
} | |
copy('non existing file a', 'non existing dir/file b', function(err){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var copy = function(inputStream, outputStream, callback){ | |
var copyNextChunk = function(){ | |
inputStream.read(fuction(err, chunk){ | |
if(err) return callback(err) | |
// When chunk == null there's no data, copying is finished. | |
if(!chunk) return callback() | |
outputStream.write(chunk, function(err){ | |
// Callback called only when chunk of data | |
// delivered to the recipient and | |
// we can send another one. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'redcarpet' | |
render = Redcarpet::Render::HTML.new \ | |
filter_html: true, | |
safe_links_only: true | |
markdown = Redcarpet::Markdown.new render, | |
autolink: true, | |
space_after_headers: true, | |
tables: true, |
OlderNewer