I've been trying to understand how to setup systems from
the ground up on Ubuntu. I just installed redis
onto
the box and here's how I did it and some things to look
out for.
To install:
# Graham Scan - Tom Switzer <thomas.switzer@gmail.com> | |
TURN_LEFT, TURN_RIGHT, TURN_NONE = (1, -1, 0) | |
def turn(p, q, r): | |
return cmp((q[0] - p[0])*(r[1] - p[1]) - (r[0] - p[0])*(q[1] - p[1]), 0) | |
def _keep_left(hull, r): | |
while len(hull) > 1 and turn(hull[-2], hull[-1], r) != TURN_LEFT: | |
hull.pop() |
var http = require('http'), | |
request = require('request'), // request module from https://github.com/mikeal/request | |
url = require('url'); | |
http.createServer(function (req, res) { | |
var href = url.parse(req.url,true).href; | |
request('http://127.0.0.1:5984' + href).pipe(res); | |
}).listen(1337); | |
// now try something like http://127.0.0.1:1337/your_db_name/_all_docs/?limit=10 |
/* converttest.js: Send a PNG of a red square to STDOUT | |
* ex. node converttest.js > test.png | |
*/ | |
var convert = require('child_process').spawn("convert", ["svg:", "png:-"]), | |
svgsrc = '<svg><rect height="100" width="100" style="fill:red;"/></svg>'; | |
convert.stdout.on('data', function (data) { | |
process.stdout.write(data); | |
}); | |
convert.stdin.write(svgsrc); | |
convert.stdin.end(); |
var data = "do shash'owania"; | |
var crypto = require('crypto'); | |
crypto.createHash('md5').update(data).digest("hex"); |
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
// Usage: | |
// var buf = new Uint8Array(128); | |
// var bitstream = new BitStream(buf); | |
// bitstream.writeBits(12, 0xffff); | |
// bitstream.seekTo(0); | |
// bitstream.readBits(6); // 111111 | |
// bitstream.readBits(10); // 1111110000 | |
window.BitStream = function(uint8Array) { |
FridayHug.com http://fridayhug.com
The Smallest Rails App http://thesmallestrailsapp.com
%w(action_controller/railtie coderay).each &method(:require)
// from google javascript style guide: | |
// One thing to keep in mind, however, is that a closure keeps a pointer to its enclosing scope. As a | |
// result, attaching a closure to a DOM element can create a circular reference and thus, a memory leak. | |
// For example, in the following code: | |
// Leaky example | |
function foo (element, a, b) { | |
element.onclick = function() { | |
// uses a and b | |
// this func keeps a pointer to foo, its enclosing scope |
<script\x20type="text/javascript">javascript:alert(1);</script> | |
<script\x3Etype="text/javascript">javascript:alert(1);</script> | |
<script\x0Dtype="text/javascript">javascript:alert(1);</script> | |
<script\x09type="text/javascript">javascript:alert(1);</script> | |
<script\x0Ctype="text/javascript">javascript:alert(1);</script> | |
<script\x2Ftype="text/javascript">javascript:alert(1);</script> | |
<script\x0Atype="text/javascript">javascript:alert(1);</script> | |
'`"><\x3Cscript>javascript:alert(1)</script> | |
'`"><\x00script>javascript:alert(1)</script> | |
<img src=1 href=1 onerror="javascript:alert(1)"></img> |