Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jaredjenkins's full-sized avatar

Jared Jenkins jaredjenkins

  • Chronosphere
  • Chicago
View GitHub Profile
package main
//#cgo pkg-config: python2.7
//#include <Python.h>
//static PyObject *runtime_log_fn;
//
//void runtime_log(char *msg)
//{
// if (runtime_log_fn == NULL) {
// free(msg);
@jaredjenkins
jaredjenkins / breadth_first_search.rb
Created February 4, 2014 20:17
Breadth First Search
class Node
attr_accessor :data, :adjacents, :visited?
def initialize(data)
self.data = data
self.visited? = false
self.adjacents = []
end
end
def bfs(node)
@jaredjenkins
jaredjenkins / depth_first_search.rb
Created February 4, 2014 20:07
Depth First Search
class Node
attr_accessor :data, :adjacents, :visited?
def initialize(data)
self.data = data
self.visited? = false
self.adjacents = []
end
end
def dfs(node)
@jaredjenkins
jaredjenkins / gist:8554909
Created January 22, 2014 07:43
Debugging GooglePlayServices availability
//copy this into an activity
public boolean isGooglePlaySdkAvailable(){
try{
Class.forName("com.google.android.gms.common.GooglePlayServicesUtil");
return true;
} catch(ClassNotFoundException exception){
logger.log(LogLevel.WARNING, "Google Play Services are not available on this device.");
}
return false;
}
id<PlaynomicsFrameDelegate> frameDelegate;
/*
frameDelegate is delegate which observes state changes in the frame:
@protocol PlaynomicsFrameDelegate <NSObject>
@optional
-(void) onShow: (NSDictionary *) jsonData;
-(void) onTouch: (NSDictionary *) jsonData;
- (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Enable test mode to view your events in the Validator. Remove this line of code before releasing your game to the app store.
[Playnomics setTestMode: YES];
const unsigned long long applicationId = <APPID>;
[Playnomics startWithApplicationId:applicationId];
//preloads the frames at game start
[Playnomics preloadFramesWithIds:@"frame-ID-1", @"frame-ID-2", @"frame-ID-2", @"frame-ID-3", nil];
//other code to initialize your iOS application below this
static public bool JsonDataContainsKey(JsonData data,string key)
{
bool result = false;
if(data == null)
return result;
if(!data.IsObject)
{
return result;
}
IDictionary tdictionary = data as IDictionary;
import logging
from termcolor import colored
class ColorLog(object):
colormap = dict(
debug=dict(color='grey', attrs=['bold']),
info=dict(color='white'),
warn=dict(color='yellow', attrs=['bold']),
brew update
brew versions FORMULA
cd `brew --prefix`
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions"
brew install FORMULA
brew switch FORMULA VERSION
git checkout -- Library/Formula/FORMULA.rb # reset formula
## Example: Using Subversion 1.6.17
#
@jaredjenkins
jaredjenkins / gist:5469066
Last active December 16, 2015 17:19
Initializing the Playnomics JavaScript API
<!-- Start Playnomics API -->
<script type="text/javascript">
_pnConfig={};
_pnConfig.userId="<USER-ID>";
var _pnAPIURL=document.location.protocol+"//js.a.playnomics.net/v1/api?a=<APPID>",
_pnAPI=document.createElement("script");
_pnAPI.type="text/javascript";_pnAPI.async=true;_pnAPI.src=_pnAPIURL;document.body.appendChild(_pnAPI);
</script>
<!-- End Playnomics API -->