Skip to content

Instantly share code, notes, and snippets.

View thejefflarson's full-sized avatar
👨‍👩‍👧‍👦
being a dad

Jeff Larson thejefflarson

👨‍👩‍👧‍👦
being a dad
View GitHub Profile
#include <gdal_priv.h>
#include <cpl_conv.h>
#include <stdio.h>
uint32_t htonf(float f){
uint32_t p;
uint32_t sign = 0;
if (f < 0) { f = 0; } // floor
glEnabled: function() {
try {
return !!window.WebGLRenderingContext &&
(!!document.createElement('canvas').getContext('experimental-webgl') ||
!!document.createElement('canvas').getContext('webgl'));
} catch(e) {
return false;
}
}
@thejefflarson
thejefflarson / state-machine.js
Last active December 17, 2015 11:19
simple state machine
(function(){
var State = function(name) {
this.name = name;
};
State.prototype.from = function(from) {
this.from_ = from;
return this;
};
var lum = function(hex) {
var bits = hex.match(/([0-9a-f]{2})/ig).map(function(i){
var it = parseInt(i, 16) / 255;
if(it < 0.03928)
return it / 12.92;
else
return Math.pow((it + 0.055) / 1.055, 2.4);
});
return 0.2126 * bits[0] + 0.7152 * bits[1] + 0.0722 * bits[2];
};
@font-face {
font-family: 'StateFaceRegular';
src: url(<%= asset_path 'stateface-regular-webfont.eot' %>);
src: url(<%= asset_path 'stateface-regular-webfont.eot?#iefix' %>) format('embedded-opentype'),
url(<%= asset_path 'stateface-regular-webfont.woff' %>) format('woff'),
url(<%= asset_path 'stateface-regular-webfont.ttf' %>) format('truetype'),
url(<%= asset_path 'stateface-regular-webfont.svg#StateFaceRegular' %>) format('svg');
font-weight: normal;
font-style: normal;
}
var alpha = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
function convert(string){
var pow = 0;
var res = 0;
while(pow < string.length){
res += (alpha.indexOf(string.split("")[pow]) + 1) * Math.pow(37, pow);
pow++;
}
return res;
# you're fucking kidding me with this shit rails
def sort_string(sort, by)
sort = Model.column_names.include?(sort) ? sort : 'field'
by = ['asc', 'desc'].include?(by) ? by : 'desc'
"#{sort} #{by}"
end
# use: Model.order(sort_string sort, by)
// Types
var one = 1;
var two = 2;
three;
window.three;
window.one = 1;
one = 1;
var one = [];
var one = {one: 1};
one.two = 1;
require 'thread'
class Pool
def initialize(csv, get, set)
@get = get
@set = set
@csv = csv
@queue = Queue.new
@mutex = Mutex.new
end
def min_hash!
min = Infinity
freq.keys.each do |key|
min = key.hash if key.hash < min
end
self.min_hash = min == Infinity ? 0 : min
end