Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Shaw petershaw

View GitHub Profile
View read char by char in swift
import Foundation
class StreamReader {
let encoding : String.Encoding
let chunkSize : Int
var fileHandle : FileHandle!
let buffer : NSMutableData!
var stored : [Character] = Array()
View Revenue of Bitstamp trades
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 Sep 30, 2014
calculate power of a thing by %
View gist:d42f7943b47e59d6ff62
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--;
}
}
View gist:bc4c3cf44ab1cb1c1741
stream of many 11's:
while (row = this.read()) {
crunchdata.avg
= +(( crunchdata.avg
+ row.temperature ) /2).toFixed(4)
;
}
= 11
View keybase.md

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 Apr 15, 2014
underscore.js - keysDeep mixin
View gist:10740305
// 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);
}
View gist:10313616
### 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:
You can’t perform that action at this time.