This is just an interactive node session, not really a code snippet.
But it's pretty instructive.
kroberts-macpro:~ kroberts$ node
> 23|0
var http = require('http'), | |
path = require('path'), | |
fs = require('fs'), | |
localPath = "/PATH/TO/LOCAL/FOLDER/", | |
remoteServer = { host: 'www.example.com', | |
port: 80 | |
}, | |
mimeTypes = { 'js' : 'text/javascript', | |
'css' : 'text/css', | |
'html' : 'text/html', |
var twitter = require('ntwitter'); | |
var twit = new twitter({ | |
consumer_key: '', | |
consumer_secret: '', | |
access_token_key: '', | |
access_token_secret: '' | |
}); | |
twit.stream('statuses/filter', {'track': 'rgiii'}, function(stream) { |
#!/usr/bin/perl -w | |
opendir DIR, "."; | |
my @files = grep { $_ ne '.' && $_ ne '..' } readdir DIR; | |
closedir DIR; | |
for $file (@files) { | |
my $lfile = lc($file); | |
if ($lfile ne $file) { | |
print $file . "\n"; |
<?php | |
//I have made a lot of nice things with PHP. But this isn't one of them. | |
if (!function_exists('lets_confuse_strings_and_symbols')) { | |
function lets_confuse_strings_and_symbols ($funny_function_name) { | |
return eval($$funny_function_name); | |
} | |
} |
//Collecting links is a below-the-api job... | |
//(http://www.forbes.com/sites/anthonykosner/2015/02/04/google-cabs-and-uber-bots-will-challenge-jobs-below-the-api/) | |
var huntsman = require('huntsman'), | |
spider = huntsman.spider(), | |
fs = require('fs'), | |
out = fs.createWriteStream('example.com.csv'); | |
spider.extensions = [ | |
huntsman.extension( 'recurse' ), // load recurse extension & follow anchor links |
var summary = require('node-tldr'), | |
sentiment = require('sentiment'), | |
opts = require('nomnom') | |
.option('url', { | |
abbr: 'u', | |
help: 'URL to summarize', | |
required: true | |
}) | |
.parse(); | |
summary.summarize(opts.url, function(result, failure) { |
var huntsman = require('huntsman'), | |
spider = huntsman.spider(), | |
fs = require('fs'), | |
opts = require('nomnom') | |
.option('domain', { | |
abbr: 'd', | |
help: 'Domain to scan.', | |
required: true | |
}) | |
.option('startUrl', { |
http://www.corporate.walmart.com/ | |
http://www.exxonmobil.com/ | |
http://www.chevron.com/ | |
http://www.berkshirehathaway.com/ | |
http://www.apple.com/ | |
http://www.phillips66.com/ | |
http://www.gm.com/ | |
http://www.ford.com/ | |
http://www.ge.com/ | |
http://www.valero.com/ |
//To understand how I started down this rabbit hole, go here: http://mechanical-sympathy.blogspot.com/2011/07/write-combining.html | |
var iterations = parseInt(2147483647 / 128); | |
//Base case, no optimization | |
function runCaseOne () { | |
console.time('caseOne'); | |
var i = iterations, | |
arrayA = [], | |
arrayB = [], |