Skip to content

Instantly share code, notes, and snippets.

<hive-validator></hive-validator>
(hive-validator.html): <div drop-target></div>
angular.module('amperApp.directives')
.directive('hiveValidator', ['hiveQueryService', function(hiveQueryService) {
return {
restrict: 'E',
templateUrl: 'partials/jobs/hive-validator.html',
replace: true,
@seanbollin
seanbollin / gist:8996997
Created February 14, 2014 07:16
Javascript Binary Tree Impl.
var binaryTree = function(rootObj) {
var that = {};
that.key = rootObj;
that.leftChild = undefined;
that.rightChild = undefined;
that.insertLeft = function(newNode) {
if (this.leftChild === undefined) {
this.leftChild = binaryTree(newNode);
@seanbollin
seanbollin / gist:8947219
Created February 12, 2014 00:09
Augmenting Types
Function.prototype.method = function(name, func) {
this.prototype[name] = func;
return this;
};
@seanbollin
seanbollin / gist:8881327
Created February 8, 2014 10:01
Recursive function to calculate XP to level
levelUpExperience: function(level) {
if (!level) { level = this.level + 1; }
if (level === 2) return 100;
return (25 * Math.pow(level, 2)) + this.levelUpExperience(level - 1);
}
@seanbollin
seanbollin / gist:8750160
Created February 1, 2014 09:43
Build universal library for XCode device and simulator
CC=clang
IPHONEOS_DEPLOYMENT_TARGET=7.0
PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH"
CFLAGS="-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -mios-simulator-version-min=7.0"
CC=clang
IPHONEOS_DEPLOYMENT_TARGET=7.0
PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH"
CFLAGS="-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -miphoneos-version-min=7.0" --host=armv7
@seanbollin
seanbollin / gist:7671006
Created November 27, 2013 05:19
Hack fix for improper image rotation in landscape-only mode for iOS, Cordova
if (CDV_IsIPhone5()) {
imageName = [imageName stringByAppendingString:@"-568h"];
}
// else if (CDV_IsIPad()) {
switch (orientation) {
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
imageName = [imageName stringByAppendingString:@"-Landscape"];
break;
@seanbollin
seanbollin / gist:7577272
Created November 21, 2013 07:14
Mongo Mapper Custom Type
class Direction
attr_reader :short, :long
def self.to_mongo(value)
case value.long
when 'north'
'n'
when 'northeast'
'ne'
when 'east'
//
// CDVSocketBridge.m
// Simple Beauty, Inc.
//
// Created by Sean Bollin on 11/11/13.
//
//
#import "CDVSocketBridge.h"
@seanbollin
seanbollin / gist:7465954
Last active December 28, 2015 07:39
mucking around with a TCP server in Ruby
require 'socket'
clients = []
server = TCPServer.open(5555)
loop {
Thread.start(server.accept) do |client|
clients << client
p clients.length
loop {
app.get('/game', function(req, res) {
console.log("request /game");
roomProvider.findById(1, function(error, docs){
currentRoom = docs;
res.render('games_index.haml', {
locals: {
title: 'RubyMUD',
room: exit_generator(docs),
isGameLayout: true
}