This file contains hidden or 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
/** | |
* Autolink urls in text | |
* Optionally autolink usernames and hashtags in twitter text | |
*/ | |
function autolink(txt){ | |
if(!txt) return; | |
var txtstr = txt + ''; //make sure it's a string | |
var url_re = /(http(s)?:\/\/[^\s)]+)/ig; | |
return txtstr.replace(url_re, '<a href="$1" target="_blank" rel="nofollow">$1</a>') || txt; |
This file contains hidden or 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
""" | |
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'))) |
This file contains hidden or 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 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())); | |
} |
This file contains hidden or 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
/** | |
* 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. |
This file contains hidden or 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
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" && \ |
This file contains hidden or 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
/* | |
* 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) { |
This file contains hidden or 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
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 [email protected] | |
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 |
This file contains hidden or 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
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'); |
This file contains hidden or 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
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) |
This file contains hidden or 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 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' |
OlderNewer