Skip to content

Instantly share code, notes, and snippets.

View evansolomon's full-sized avatar

Evan Solomon evansolomon

View GitHub Profile

Keybase proof

I hereby claim:

  • I am evansolomon on github.
  • I am evansolomon (https://keybase.io/evansolomon) on keybase.
  • I have a public key whose fingerprint is 681D CFF5 F3F1 3E5D 54C3 CFBF ED5A 7031 FB5C 6B36

To claim this, I am signing this object:

@evansolomon
evansolomon / gist:9535323
Created March 13, 2014 19:36
Even when you don't care about a stream's data, you need to make sure it's produced.
var https = require('https')
https.get('https://medium.com', function (res) {
res.on('end', function () {
console.log('You will never see this')
})
})
https.get('https://medium.com', function (res) {
// This sets the stream to flowing mode and makes sure it gets through all of its
$ aws lambda get-event-source --uuid my-events-uuid
{
"Status": "OK",
"UUID": "my-events-uuid",
"LastModified": "2014-11-22T02:37:00.000+0000",
"BatchSize": 1,
"Parameters": {
"InitialPositionInStream": "TRIM_HORIZON"
},
"Role": "arn:aws:iam::acct-number:role/lambda_exec_role",
This file has been truncated, but you can view the full file.
{"participants":303854,"now":1427930520000,"secondsLeft":60}
{"participants":303865,"now":1427930521000,"secondsLeft":60}
{"participants":303871,"now":1427930522000,"secondsLeft":60}
{"participants":303875,"now":1427930523000,"secondsLeft":60}
{"participants":303884,"now":1427930524000,"secondsLeft":60}
{"participants":303893,"now":1427930525000,"secondsLeft":60}
{"participants":303900,"now":1427930526000,"secondsLeft":60}
{"participants":303907,"now":1427930527000,"secondsLeft":60}
{"participants":303917,"now":1427930528000,"secondsLeft":60}
{"participants":303931,"now":1427930529000,"secondsLeft":60}
@evansolomon
evansolomon / xhr.js
Created May 21, 2015 18:46
Chrome 43 changed the way XMLHttpRequest objects get serialized to JSON. Almost all of the fields as missing now.
var xhr = new XMLHttpRequest()
xhr.open('GET', 'http://requestb.in/155pmaz1')
xhr.onreadystatechange = function () {
if (xhr.readyState !== 4) return
var jsonifiedXhr = JSON.parse(JSON.stringify(xhr))
console.log(Object.keys(jsonifiedXhr))
}
xhr.send()
// Chrome 42
@evansolomon
evansolomon / gist:7ebcb5e4ae331e1997cd
Created July 8, 2015 19:30
react-native init tree
.
├── JSONStream
│   ├── LICENSE.APACHE2
│   ├── LICENSE.MIT
│   ├── examples
│   │   └── all_docs.js
│   ├── index.js
│   ├── package.json
│   ├── readme.markdown
│   └── test
@evansolomon
evansolomon / nfl_players.php
Created November 26, 2010 07:31
Find links for all active NFL player profiles on nfl.com
<?php
$results = array();
$r_players = '/\/players\/(.+?)\/profile\?id\=[A-Z0-9]+/';
for($i='a';$i!='c';$i++){
$base = 'http://www.nfl.com/players/search?category=lastName&filter='.$i.'&playerType=current';
$url = $base;
$d = 2;
$page_check = 1;
@evansolomon
evansolomon / gist:945513
Created April 28, 2011 00:00
French Laundry Alerts
<?php
//number of people in the reservation
$people = 2;
//time, just the hour, pm
$time = 7;
$url = 'http://www.opentable.com/nextavailabletable.aspx?hpu=1025002033&shpu=1&rid=1180&m=4&d=8/13/2010+'.$time.':00:00+PM&p='.$people;
$data = file_get_contents($url);
$regex = '/\[\'\d{1,2}\/\d{1,2}\/\d{4} \d{1,2}\:\d{2}\:\d{2} PM/';
@evansolomon
evansolomon / kissmetrics.php
Created December 3, 2011 23:11
Kissmetrics plugin for WordPress with a simplified class based on their default library
<?php
/*
Plugin Name: WP Kissmetrics
Description: Record events using Kissmetrics' PHP API. Intended to be used by developers only.
Author: evansolomon
Version: 1.0
*/
/* Forked from https://github.com/kissmetrics/KISSmetrics/blob/master/km.php */
@evansolomon
evansolomon / gist:1453969
Created December 10, 2011 00:22
Do something when a WordPress user uploads a video
<?php
/**
* User uploads a video
*/
function user_uploads_video( $args, $upload ) {
if( 'upload' != $upload )
return;
if( 0 === strpos( $args['type'], 'video' ) ) {
//do cool stuff