Skip to content

Instantly share code, notes, and snippets.

View jaybaird's full-sized avatar

Jay Baird jaybaird

  • Ferndale, WA
View GitHub Profile
@jaybaird
jaybaird / glm_kazmath.diff
Created June 15, 2016 19:46 — forked from fhssn1/glm_kazmath.diff
Some examples of equivalence of OpenGL math libraries glm (C++) and kazmath (C)
--- p6.cpp 2014-03-28 22:55:37.000000000 -0500
+++ p6.c 2014-03-28 23:02:28.000000000 -0500
@@ -7,9 +7,8 @@
#define PNG_DEBUG 3
#include <png.h>
-#include <glm/glm.hpp>
-#include <glm/gtc/matrix_transform.hpp>
-#include <glm/gtc/type_ptr.hpp>
+#include <kazmath/kazmath.h>
@jaybaird
jaybaird / lua-uuid.lua
Last active October 24, 2015 11:15 — forked from jrus/lua-uuid.lua
local random = math.random
local function uuid()
local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
return string.gsub(template, '[xy]', function (c)
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
return string.format('%x', v)
end)
end
### Keybase proof
I hereby claim:
* I am jaybaird on github.
* I am jaybaird (https://keybase.io/jaybaird) on keybase.
* I have a public key whose fingerprint is 03D2 571D BB3B 13EA 14DF 41EB E387 51C8 785C 80DE
To claim this, I am signing this object:
@jaybaird
jaybaird / gist:6003951
Last active December 19, 2015 19:09
Binary Tree with NSArray
#import <Foundation/Foundation.h>
@interface Node : NSObject
@property (nonatomic) NSInteger identifier;
@property (nonatomic, copy) NSString *value;
+ (Node *)nodeWithIdentifier:(NSInteger)identifier value:(NSString *)value;
@end
@implementation Node
+ (Node *)nodeWithIdentifier:(NSInteger)identifier value:(NSString *)value {
@jaybaird
jaybaird / Analytics.h
Created February 5, 2013 01:45
Sensible analytics functions using LLVM's overloadable
NSString * eventForCategoryAction(NSString *category, NSString *action) {
return [NSString stringWithFormat:@"%@:%@", (category) ? category : @"default", action]
}
void __attribute__((overloadable)) TrackEvent(NSString *category, NSString *action, NSDictionary *infoDict) {
[Flurry trackEvent:eventForCategory(category, action) withParameters:infoDict];
}
void __attribute__((overloadable)) TrackEvent(NSString *category, NSString *action) {
TrackEvent(category, action, nil);
package my.elasticsearch;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@jaybaird
jaybaird / gist:967743
Created May 12, 2011 01:13
SWF Detect
javascript:(function() {
var object_tags = document.getElementsByTagName('object');
var embed_tags = document.getElementsByTagName('embed');
var filter = new RegExp('.*?((?:[a-z][a-z\\.\\d\\-]+)\\.(?:[a-z][a-z\\-]+))(?![\\w\\.])');
var pullUrls = function(elements, attr) {
var urls = [];
for (var i=0; i < elements.length; i++) {
var data = elements[i].getAttribute(attr);
import foo