Skip to content

Instantly share code, notes, and snippets.

View mathisonian's full-sized avatar

Matthew Conlen mathisonian

View GitHub Profile
@mathisonian
mathisonian / gist:3881421
Created October 12, 2012 20:51
node.js and mongolab on heroku
// Get the connection uri and set it up for processing
var uri = process.env.MONGOLAB_URI;
var uri = uri.slice(uri.indexOf('/')+1);
var user = uri.substring(1, uri.indexOf(':'));
var pass = uri.substring(uri.indexOf(':')+1, uri.indexOf("@"));
var dbName = uri.substring(uri.lastIndexOf("/")+1);
var port = uri.substring(uri.lastIndexOf(":") + 1, uri.lastIndexOf("/"));
var host = uri.substring(uri.lastIndexOf("@") + 1, uri.lastIndexOf(":"));
@mathisonian
mathisonian / gist:5573378
Created May 14, 2013 03:08
print ios fonts
for (NSString *familyName in [UIFont familyNames]) {
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(@"%@ - %@", familyName, fontName);
}
}
@mathisonian
mathisonian / gist:5573402
Created May 14, 2013 03:14
ligatures and symbol fonts on ios
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"camera"];
[string setAttributes:@{(NSString *)kCTLigatureAttributeName:[NSNumber numberWithInt:2]} range:NSMakeRange(0, string.length)];
self.myUILabel.attributedText = string;
var svg = d3.select('#example-1')
.append('svg')
.attr('width', 202)
.attr('height', 202);
var data = d3.range(10).map(function (d, i) {
return i;
});
var svg = d3.select('#example-3')
.append('svg')
.attr('width', '100%')
.attr('viewBox', '0 0 202 202');
var data = d3.range(10).map(function (d, i) {
return i;
});
var aspectRatio= '16:9';
var viewBox = '0 0 ' + aspectRatio.split(':').join(' ');
var svg = d3.select('#example-4')
.append('svg')
.attr('width', '100%')
.attr('viewBox', viewBox);
// draw the background
// This can be generalized to arbitrary
// aspect ratios. See last example for
// more on that.
// See calculation for total size in
// example above
var size = 202;
// 1st example - set an explicit
// Assume a variable called `svg`
// has already been created,
// corresponding to a d3 selection
// of an SVG element.
//
// For this example take the
// 'size' of the svg to be 202x202 pixels
var marginSize = 1;
@mathisonian
mathisonian / test.md
Created March 11, 2016 04:14
test title

test.1

var _ = require('lodash');
var d3 = require('d3');
function randomVariable(rate) {
rate = rate || 1;
var U = Math.random();
return -Math.log(U)/rate;
};
var start = 0;