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
// round down to multiple of 1024 | |
size_t roundDown(size_t s) { | |
return s & ~1023; | |
} | |
// round up to multiple of 1024 | |
size_t roundUp(size_t s) { | |
return (s + 1023) & ~1023; | |
} |
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 util = require('util'); | |
var fs = require('fs'); | |
var type = function(data, completer) { | |
var lines = data.split(' '); | |
var i = 0; | |
var timer = setInterval(function() { | |
var s = lines[i++]; | |
while (lines[i] == '') { |
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
<html> | |
<head> | |
<script type="text/javascript"> | |
function shorten() { | |
var s = document.getElementById("url").value.match(/^https?:\/\/[^/]*\bflickr\.com\/(photos\/[^/]+\/(\d+))/i); | |
if (s && s.length && s[2]) { | |
var num = s[2]; | |
if (typeof num !== 'number') { | |
num=parseInt(num); | |
} |
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
#!/usr/local/bin/node | |
var assert = require('assert'); | |
// utils | |
Array.prototype.swap = function(a, b) { | |
if (a == b) { | |
return; | |
} | |
var tmp = this[a]; |
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
#!/usr/local/bin/node | |
var fs = require('fs'); | |
var file = process.argv[2]; | |
if (!file) throw 'no input file'; | |
var seq = false; | |
if (file == '-s') { | |
if (!process.argv[3]) throw 'no input file'; |
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
Alice|Bob|Carol | |
1|1->2|INVITE(hello) | |
2|2->3|INVITE | |
-|3|waiting... | |
3|2<-3|200OK | |
4|1<-2|200OK |
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
#!/usr/local/bin/node | |
var fs = require('fs'); | |
Function.prototype.mlstr = function() { | |
var lines = new String(this); | |
return lines.substring(lines.indexOf("/*") + 2, lines.lastIndexOf("*/")); | |
}; | |
String.prototype.dup = function(n) { | |
var sb = ''; |
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
#!/usr/local/bin/node | |
var Registry = function() { | |
this.r = [null]; | |
}; | |
Registry.prototype.register = function(object) { | |
var id = this.r[0]; | |
if (id === null) { | |
this.r.push(object); |
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
#include <iostream> | |
#include <string> | |
using namespace std; | |
std::string escapeXml(const std::string& s) { | |
std::string ret; | |
std::string::size_type i = 0; | |
std::string::size_type pos = 0; | |
for (; i != s.size(); ++i) { | |
std::string rep; |
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
#ifndef EXPECTED_H | |
#define EXPECTED_H | |
#include <exception> | |
#include <typeinfo> | |
// Make exceptions be the error codes! | |
template <typename T> | |
class Expected { | |
public: |
OlderNewer