Skip to content

Instantly share code, notes, and snippets.

View bengotow's full-sized avatar

Ben Gotow bengotow

View GitHub Profile
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN"
"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html version="XHTML+RDFa 1.1" xmlns="http://www.w3.org/1999/xhtml"
prefix="xhv: http://www.w3.org/1999/xhtml/vocab#
xsd: http://www.w3.org/2001/XMLSchema#
rdfs: http://www.w3.org/2000/01/rdf-schema#
dc: http://purl.org/dc/terms/
vcard: http://www.w3.org/2006/vcard/ns#
v: http://rdf.data-vocabulary.org/#"
lang="en" >
@bengotow
bengotow / RubyMotion_Setup.md
Last active December 17, 2015 04:39
Living document with information about adding the Spark Inspector framework into a RubyMotion project

###Add the Spark Inspector to a RubyMotion Project

Please give these instructions a try and let me know how it goes - it should be possible to get the Spark Inspector working. I don't own a copy of RubyMotion yet, but I identified the vendor_project options I think you'll need to include and link the Inspector's framework into your app.

UPDATE: @tbdr has confirmed that the instructions below work. Feel free to comment below if you discover issues!

UPDATE 2: @tbdr has published a gem motion-sparkinspector to make this easier. Source available https://github.com/TBD/motion-sparkinspector.

  1. Download the Spark Inspector from http://www.sparkinspector.com/
@bengotow
bengotow / gist:9433828
Created March 8, 2014 15:52
Objective-C convenience methods for abstracting timing dependency
- (void)example
{
NSTextView * console = [self xcodeConsoleIn: IDEWindow];
NSInteger baseLength = [[console string] length] + [command length];
[_log appendFormat: @"\n Writing into console: %@", command];
[console insertText: command];
[console insertNewline:nil];
@bengotow
bengotow / server.py
Last active August 29, 2015 14:04
A simple implementation of the authorization flow for Inbox. Presents a sign in page, and then displays the first message from the user's inbox once they've signed in.
#!/usr/bin/env python
# NOTE: This sample app does NOT use SSL. Before deploying this code to a
# server environment, you should ENABLE SSL to avoid exposing your API
# access token in plaintext.
# To run this demo app:
# 1. Save this file to your computer as `server.py`
#
# 2. In the Inbox Developer Portal, create a new application. Replace the
### Keybase proof
I hereby claim:
* I am bengotow on github.
* I am bengotow (https://keybase.io/bengotow) on keybase.
* I have a public key whose fingerprint is 74AB 1024 E78C 6F3A 12F1 D92C C034 F07C CC52 32D1
To claim this, I am signing this object:
@bengotow
bengotow / pong.rb
Created August 22, 2014 01:05
Ping back and forth between two email accounts over and over forever using Inbox
#!/usr/bin/env ruby
require 'inbox'
@inbox_careless = Inbox::API.new('xdfim6g4mbduytzjhn8ud490', '80q785tt4l6qn5g07c5ylwi6a', '<<token 1>>')
@inbox_emoink = Inbox::API.new('xdfim6g4mbduytzjhn8ud490', '80q785tt4l6qn5g07c5ylwi6a', '<<token 2>>')
emoink = @inbox_emoink.namespaces.first
careless = @inbox_careless.namespaces.first
while true do
@bengotow
bengotow / app.js
Created August 7, 2015 19:42
concurrency - rolling average
var Promise = require('bluebird');
var request = Promise.promisify(require('request'));
var fs = require('fs');
global.Nylas = require('nylas').config({
appId: '1',
appSecret: '2',
apiServer: 'https://api.nylas.com'
});
*:
signatures:
"<ACCOUNT ID>": "<br>Test User<br>XXX-XXX-XXXX<br>test@example.com"
@bengotow
bengotow / Comparison.txt
Created March 17, 2016 19:27
Comparison of SQL Approaches for Counting Threads
Option A: Two Subqueries
SELECT
`Thread-Category`.`value` as category_id,
COALESCE((SELECT unread FROM `Thread-Counts` WHERE category_id = `Thread-Category`.`value`), 0) + SUM(unread) as unread,
COALESCE((SELECT total FROM `Thread-Counts` WHERE category_id = `Thread-Category`.`value`), 0) + COUNT(*) as total
FROM `Thread`
INNER JOIN `Thread-Category` ON `Thread`.`id` = `Thread-Category`.`id`
WHERE
`Thread`.in_all_mail = 1
@bengotow
bengotow / spdlog-extensions.cpp
Created August 30, 2017 21:23
SPDLog Sink for "Flush Within Xmsec"
/*
The code below shows a custom SPDLog sink that uses a separate thread and a C++0x condition_variable
to ensure that a spdlog::sinks::rotating_file_sink_mt is flushed to disk within a second of a new
log message being emitted. When no messages are arriving, the helper thread has very low wake overhead
and sleeps for 30s.
*/
std::mutex spdFlushMtx;
std::condition_variable spdFlushCV;
int spdUnflushed = 0;