Skip to content

Instantly share code, notes, and snippets.

@tbuchok
tbuchok / scrape-cio.js
Last active November 9, 2015 16:46 — forked from carlsednaoui/scrape-cio.js
Get stats from Customer.io
// doesn't work yet :)
var selectors = [
'.name',
'.created',
'td p:first-child',
'.updated',
'.unsent',
'.sent',
'.opened',
'.clicked',
insert into emails where guid = '123abc' (duplicate_ids) values (['456feg', '789wer']);
@tbuchok
tbuchok / fake-readable.js
Last active August 29, 2015 13:59
readable streams are fun.
var Readable = require('stream').Readable
, util = require('util')
;
util.inherits(FakeReadable, Readable);
function FakeReadable(options) {
var self = this;
Readable.call(self);
self.push(new Buffer('data'));
setTimeout(function() {
@tbuchok
tbuchok / coderbyte.js
Last active January 3, 2016 15:39 — forked from robpe/coderbyte.js
function fn(array) {
return array
.sort(function(a,b) { return a - b })
.reduce(function(sum, val, idx, sorted) {
// this still has holes in it, not testing correct things:
return (idx == sorted.length - 1) ? sum > sorted[idx] : sum + val;
}, 0);
}
console.log('[4, 6, 23, 10, 1, 3]', fn([4, 6, 23, 10, 1, 3])); //=> true
@tbuchok
tbuchok / scratch.md
Last active December 29, 2015 03:49
thinking out loud about email templates

Compose Email Templates

Enhance existing template languages with filters to allow email marketers to focus on design and content, not esoteric email client development.

Below takes a stab using the Jade templating language.

Example

:email(width = 640)
  :preheader
:email
:section(width = 640)
a(href = '#')
p Lorem ipsum dolor
@tbuchok
tbuchok / _server.jsx
Last active December 18, 2015 03:29
Talking to Photoshop over TCP
(function() {
var loop = true,
tcp = new Socket,
psd = app.activeDocument; // i.e., `psd` is the current open document in Photoshop.
var run = function() {
// Server is running a port 1234:
while(loop) {
var connection = tcp.poll();
if (connection != null) {
@tbuchok
tbuchok / sample.js
Last active December 16, 2015 23:59
var request = require('request')
, uri = 'http://domain.com/long_file.mp3';
// assumes `res` is a response object
request(uri).pipe(res);
@tbuchok
tbuchok / sample.rb
Last active December 16, 2015 23:59
require 'open-uri'
uri = 'http://domain.com/long_file.mp3'
# assumes `send_data` sends response:
send_data(open(uri).read, type: 'audio/mpeg')