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:4067528
Created November 13, 2012 18:34
Getting the starting index of selected text
/*
* Gets the starting index of the selected text
*/
function _getSelectionHtml() {
/*
* Returns HTML String of current selection
*/
var html = "";
@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;
@mathisonian
mathisonian / emoji-support.js
Created December 10, 2013 03:24
Detect emoji support
/**
* Determine if this browser supports emoji.
*
* Modified from https://gist.github.com/mwunsch/4710561
* and probobly originally github's javascript source
*/
function doesSupportEmoji() {
var context, smiley;
if (!document.createElement('canvas').getContext) return;
context = document.createElement('canvas').getContext('2d');
@mathisonian
mathisonian / index.js
Last active July 25, 2023 21:42
postgres full text search in sequelize.js. see this blog post for more information http://www.mathisonian.com/weblog/postgres-full-text-search-with-sequelizejs
var Sequelize = require('sequelize');
module.exports = function(config) {
var models = {};
sequelize = new Sequelize(config.database, config.username, config.password, config.options);
// Bootstrap models
fs.readdirSync(__dirname).forEach(function (file) {
@mathisonian
mathisonian / .gitignore
Created February 14, 2014 23:03
node gitignore
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
*.tmp
*.db
@mathisonian
mathisonian / Preferences.sublime-settings
Created April 15, 2014 18:17
sublime text options for command line usage
{
"remember_open_files": false,
"hot_exit": false
}

Mouseover to see flights originating at the specified airport. The cool thing about this technique is that the interaction requires zero JavaScript — it’s all done in CSS using the :hover state to toggle visibility of an airport’s associated outgoing flight routes.

@mathisonian
mathisonian / colors.pde
Created May 9, 2014 15:21
cosmic latte gradients
void setup() {
size(640, 360);
colorMode(HSB, 360, 1, 1);
background(0);
}
void draw() {