Skip to content

Instantly share code, notes, and snippets.

"""
various python utils just for my reference
"""
# convert string to datetime
import time
from datetime import datetime
day = datetime.fromtimestamp(time.mktime(time.strptime(d, '%B %d, %Y')))
var sys = require('sys');
var XML = require('libxmljs');
var doc = null;
function mem() {
sys.debug(sys.inspect(process.memoryUsage()).replace(/\n/g, ''));
sys.debug(sys.inspect(XML.memoryUsage()));
}
/**
* simple.tal file
<?xml version="1.0" encoding="UTF-8"?>
<div xmlns:tal="http://axiomstack.com/tale">
<p id="testing" tal:omit="true">
Hello <span tal:content="data.name"/>
You have just won $<span tal:content="data.value"/>!
<span tal:if="data.in_ca">
Well, $<span tal:content="data.taxed_value"/>, after taxes.
diff --git a/nvm.sh b/nvm.sh
index 7aaac55..5536c6e 100644
--- a/nvm.sh
+++ b/nvm.sh
@@ -38,7 +38,7 @@ nvm()
cd "$NVM_DIR/src" && \
git clone git://github.com/ry/node.git && \
cd node && \
- ./configure --prefix="$NVM_DIR/HEAD" && \
+ ./configure --debug --prefix="$NVM_DIR/HEAD" && \
/*
* Simple example of using fs methods to append to a file
*/
var sys = require('sys'),
fs = require('fs');
fs.open('my.log', 'a', undefined, function(err, fd) {
if(err) throw err;
fs.write(fd, 'Appending to this file\n', undefined, undefined, function(err, written) {
npm configfile /Users/polotek/.npmrc
npm sudo false
npm install pkg npm
npm fetch data npm
npm response
npm install pkg npm
npm install pkg npm@0.1.4
npm install pkg http://github.com/isaacs/npm/tarball/v0.1.4
npm fetch http://github.com/isaacs/npm/tarball/v0.1.4 to /Users/polotek/.node_libraries/.npm/.tmp/http---github-com-isaacs-npm-tarball-v0-1-4-1273332589145-0.8430941854603589.tgz
npm fetch http://github.com/isaacs/npm/tarball/v0.1.4
process.addListener('uncaughtException', function(err) {
throw err;
});
var sys = require('sys')
, fs = require('fs')
, http = require('http');
http.createServer(function (req, res) {
sys.debug(req.url);
req.setEncoding('utf8');
TypeError: Cannot call method 'lastIndexOf' of null
at Object.basename (path:48:28)
at resolveModulePath (module:192:13)
at loadModule (module:206:24)
at require (module:364:12)
at REPLServer.<anonymous> (eval at <anonymous> (repl:68:28))
at REPLServer.readline (repl:68:19)
at Stream.<anonymous> (repl:29:19)
at Stream.emit (events:25:26)
at IOWatcher.callback (net:387:16)
var sys = require('sys')
, fs = require('fs')
, http = require('http');
var STREAM_HOST = 'stream.twitter.com';
var client = http.createClient(80, STREAM_HOST);
var headers = {
'Host': STREAM_HOST
, 'User-Agent': 'node.js'