Skip to content

Instantly share code, notes, and snippets.

import Foundation
class StreamReader {
let encoding : String.Encoding
let chunkSize : Int
var fileHandle : FileHandle!
let buffer : NSMutableData!
var stored : [Character] = Array()
use strict;
use warnings;
## Login your account,
## export the transactions as csv
## run the script
my $file = './Transactions.csv';
open my $info, $file or die "Could not open $file: $!";
@petershaw
petershaw / gist:d42f7943b47e59d6ff62
Created September 30, 2014 21:55
calculate power of a thing by %
var power = 80;
var state = 1;
for(turn=0;turn<100;turn++){
if((turn % power) > 0){
if(state){console.log(". ", turn);} else {console.log("ON", turn);}
} else {
state--;
}
}
stream of many 11's:
while (row = this.read()) {
crunchdata.avg
= +(( crunchdata.avg
+ row.temperature ) /2).toFixed(4)
;
}
= 11

Keybase proof

I hereby claim:

  • I am petershaw on github.
  • I am kriswolff (https://keybase.io/kriswolff) on keybase.
  • I have a public key whose fingerprint is 8F2D 60BC BB9C 9CC7 C924 CEC1 4F18 E779 3342 6638

To claim this, I am signing this object:

@petershaw
petershaw / gist:10740305
Created April 15, 2014 15:10
underscore.js - keysDeep mixin
// returns all keys of a given object in any level depth
// ------------------------------------------------------
_.mixin({
keysDeep: function (obj) {
var extract = function (obj, result) {
_.each(_.keys(obj), function(elm) {
if(_.isString(obj[elm])){
result.push(elm);
}
@petershaw
petershaw / gist:10313616
Created April 9, 2014 20:49
keybase.md
### Keybase proof
I hereby claim:
* I am petershaw on github.
* I am petershaw (https://keybase.io/petershaw) on keybase.
* I have a public key whose fingerprint is D94C 0B8C 65DF 7D9B 7F09 026B 5FB6 A5D2 8960 E426
To claim this, I am signing this object: