Skip to content

Instantly share code, notes, and snippets.

View jaredjenkins's full-sized avatar

Jared Jenkins jaredjenkins

  • Chronosphere
  • Chicago
View GitHub Profile
@jaredjenkins
jaredjenkins / ConcurrentQueue.cs
Last active November 13, 2017 00:00
Concurrent Queue for Unity
using System;
using System.Collections.Generic;
namespace PlaynomicsPlugin
{
internal class ConcurrentQueue<T>{
private readonly object syncLock = new object();
private Queue<T> queue;
@jaredjenkins
jaredjenkins / gist:5421985
Created April 19, 2013 17:53
Parallel http requests in Unity
private IEnumerator ProcessRequests()
{
if(isProcessing || taskQueue.Count == 0){
yield break;
}
isProcessing = true;
//get a temp variable, otherwise we could be stuck in an infinite-loop (offline scenario)
int itemsToProcess = taskQueue.Count;
while(itemsToProcess > 0){
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 / 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 -->