Skip to content

Instantly share code, notes, and snippets.

@esromneb
esromneb / .gitconfig
Created June 14, 2012 23:13 — forked from roolo/.gitconfig
git-merge with KDiff3 on Mac OS X Lion
# This is file ~/.gitconfig
[merge]
tool = extMerge
[mergetool "extMerge"]
cmd = ~/bin/extMerge.sh \"$BASE\" \"$LOCAL\" \"$REMOTE\" -o \"$MERGED\"
@esromneb
esromneb / convert.m
Created August 20, 2012 09:46
Convert MKMapRect to CLRegion aka convert visible region of mapview to CLRegion
- (CLLocationDistance)getDistanceFrom:(CLLocationCoordinate2D)start to:(CLLocationCoordinate2D)end
{
CLLocation *startLoc = [[CLLocation alloc] initWithLatitude:start.latitude longitude:start.longitude];
CLLocation *endLoc = [[CLLocation alloc] initWithLatitude:end.latitude longitude:end.longitude];
CLLocationDistance retVal = [startLoc distanceFromLocation:endLoc];
[startLoc release];
[endLoc release];
return retVal;
}
@esromneb
esromneb / gist:5651374
Created May 26, 2013 01:11
Quick intro on how to do ajax on rails. This was simplified from my autocomplete code. In this example the autocomplete is removed and just ajax is presented.
#routes.rb
get 'scraped_episodes_search' => 'scraped_episodes#search'
#scraped_episodes_controller.rb
# used for autocomplete search
def search
// https://gist.github.com/Yaffle/1287361
var crc32table = null;
crc32 = function(s) {
s = String(s);
var polynomial = 0x04C11DB7,
initialValue = 0xFFFFFFFF,
finalXORValue = 0xFFFFFFFF,
crc = initialValue,
i, j, c;
module CustomColumnTypes
def double(*args)
if !args.last.is_a? Hash
args.push({})
end
args.last[:limit] = 53
float *args
end
@esromneb
esromneb / gist:6395247
Created August 30, 2013 23:29
Generate a "websocket style" length header
// only supports messages up to 65536 characters long
// takes a first param of byte_count and generates the correct "websocket style" header
// *header_len is set to the number of bytes used in header[]
void build_message_header(const size_t byte_count, char header[3], size_t* header_len)
{
size_t len = byte_count;
if( len < 126 )
{
header[0] = len & 0xff;
*header_len = 1;
@esromneb
esromneb / gist:7936719
Created December 12, 2013 22:30
Handy macros for byte operations as well as set and get bits
/**************************************************************************************************
* Filename: hal_defs.h
* Description: This file contains useful macros and data types
*
*
* Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@esromneb
esromneb / userSettings.js
Created January 17, 2014 00:01
Drop this in /lib/ in your meteor app for a very simple user settings wrapper
function isArray(x) {
return _.isArray(x) && !EJSON.isBinary(x);
}
// pulled from "LocalCollection._makeLookupFunction"
var dotNotationFetch = function (key) {
var dotLocation = key.indexOf('.');
var first, lookupRest, nextIsNumeric;
if (dotLocation === -1) {
first = key;
L.Control.Button = L.Control.extend({
options: {
position: 'bottomleft'
},
initialize: function (options) {
this._button = {};
this.setButton(options);
},
@esromneb
esromneb / email.js
Last active February 12, 2016 18:58
Name this file server/email.js and then also add that to your .gitignore
// put me at server/email.js
Meteor.startup(function () {
var user = "user";
var password = "password";
var serverAndPort = "smtp.example.com:9999";
var string = 'smtp://' + user + ':' + password + '@' + serverAndPort;
process.env.MAIL_URL = string;
});