Skip to content

Instantly share code, notes, and snippets.

View skeggse's full-sized avatar
⚠️
Drop ICE

Eli Skeggs skeggse

⚠️
Drop ICE
View GitHub Profile
@skeggse
skeggse / play-store-reviews.js
Created December 12, 2013 09:21
Simple (and pretty bad) scraper for Google Play Store reviews.
var scan = (function(window, document) {
/**
* Scans through all the pages and maps all the reviews.
*
* TODO: automatically switch to date-ordered reviews, and page backwards to
* beginning.
*
* @param {function(?Error, Object, Array)} callback The callback when all reviews have
* been found.
*/
/**
* @param {Object.<string, boolean>} data
* @return {number}
*/
function hello(data) {
var q = 0;
if (data.a) {
if (data.b && data.c) {
q = 1
} else if (data.d) {
@skeggse
skeggse / a-test.js
Last active December 28, 2015 16:59
An unexpected abort and subsequent core dump when using the dgram module
var dgram = require('dgram');
var socket = dgram.createSocket('udp4');
// looks like the send might not need to be in the bind callback
socket.bind(8001, '0.0.0.0', function() {
socket.send(new Buffer('HELO'), 0, 4, 8001, 'localhost');
});
socket.on('message', function ondata(data, rinfo) {
@skeggse
skeggse / test.sh
Created November 8, 2013 23:53
O.o
#!/bin/bash
echo "echo Again." >> ~/test.sh
echo Hello.
var numApples = 5;
function handleConn(name) {
var pickedApples = 0;
return function pick() {
pickedApples++;
numApples--;
console.log(name, 'has', pickedApples, 'apples');
};
var net = require('net');
var EventEmitter = require('events').EventEmitter;
// just define this in the file scope, you don't need to assign it as a property
var numApples = 50;
// pickers, because this can handle multiple pickers
var fruitPickers = new EventEmitter();
// replentish apples every thirty seconds
@skeggse
skeggse / consumer.js
Created October 3, 2013 00:44
A Node.js backpressure example over a tcp/net stream. Just run index.js, the output is a little shoddy but it works. The producer only produces once the consumer catches up, but the streams are disconnected--they can't communicate directly.
var net = require('net');
var util = require('util');
var Writable = require('stream').Writable;
/**
* Pretends to consume the data written to it. In reality, it just eats data
* really slowly.
*
* @constructor
* @extends Writable
function factorial(n) {
if (n == 0)
return 1;
return n * factorial(n - 1);
}
function factorialb(n) {
var b = 1;
while (n)
b *= n--;
@skeggse
skeggse / udpstream.js
Created July 11, 2013 18:09
Node Streams2 UDPStream Implementation
var dgram = require('dgram');
var _ = require('underscore');
var thumbs = {
twiddle: function() {}
};
_.mixin({
options: function(self, options, defaults) {
if (options)
!!!5
html(lang="en")
head
title= title
link(rel='stylesheet', type='text/css', href='/stylesheets/style.css')
body
#account_manager
#sign_in Sign in
#sign_up Sign up
#top