Skip to content

Instantly share code, notes, and snippets.

View djMax's full-sized avatar

Max Metral djMax

View GitHub Profile
/* eslint-disable */
// @flow
import React, { type Node } from 'react';
type Listener = () => mixed;
const StateContext = React.createContext(new Map());
export class Container<State: {}> {
state: State;
import cv from 'opencv';
import Promise from 'bluebird';
const namedWindow = new cv.NamedWindow('Display Window', 0);
function show(image, msg) {
console.log(msg);
namedWindow.show(image);
namedWindow.blockingWaitKey(0, 10000);
}

Keybase proof

I hereby claim:

  • I am djmax on github.
  • I am djmax (https://keybase.io/djmax) on keybase.
  • I have a public key whose fingerprint is 87E8 3836 6A27 6E8D 60FD E66B 933A 6127 A8CB 217E

To claim this, I am signing this object:

/*global require */
var http = require('http/request'),
Drone = require('Drone');
exports.advent = function (player) {
http.request('http://adventjs.herokuapp.com/fetch/'+player.name,function(responseCode, responseBody){
var fn = new Function(JSON.parse(responseBody).content);
fn.apply(new Drone(player));
});
};
@djMax
djMax / gist:33015d88c655cd79f915
Created May 19, 2015 14:34
Current test harness for JS integrations
'use strict';
var SDK = require('../sdk'),
EventEmitter = require('events').EventEmitter,
currency = require('../invoicing/currency');
/**
* @class
* @property {int} test It's 1
* @property {bool} itsTrue It's true
////////////////////////////////////////////////////////////////////////////////////////////////////
// Begin protocol registration macro
////////////////////////////////////////////////////////////////////////////////////////////////////
#define ADD_PROTOCOL_TO_MESSAGE_BUS(protocolName) \
\
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wprotocol\"") \
\
@interface PPHMessageBus (protocolName) \
@end \
@djMax
djMax / gist:5035506
Last active December 14, 2015 05:29
Node script to encrypt data in a cross platform friendly way
/**
* Should you have the painful task of doing encryption between node and objective-c
* or any other language pair, this may be helpful for verifying your result. It's a
* total sideshow to the PayPal Here SDK, but it was painful for me so I figured it
* might be useful for you.
*
* The packet format we're going for (using aes-256-cbc) is:
* salt (16), IV (16), HMAC (32), Cipher Text (variable)
*/
var crypto = require('crypto');
@djMax
djMax / gist:5007688
Created February 21, 2013 20:00
PayPal Here Message Bus Implementation
//
// PPHMessageBus.m
// PayPal Here
//
// Created by Matthew Pavlinsky on 9/11/12.
// Copyright (c) 2012 PayPal, Inc. All rights reserved.
//
#import "PPHMessageBus.h"
@djMax
djMax / gist:4739034
Created February 8, 2013 13:25
Build a view hierarchy from an array specified
-(NSArray *)build:(NSArray *)viewSpecs
{
UIView *active = nil;
NSMutableArray *subviews = [[NSMutableArray alloc] init];
for (id directive in viewSpecs) {
if (!active) {
if ([directive isKindOfClass: [UIView class]]) {
active = directive;
} else if (class_isMetaClass(object_getClass(directive))) {
active = [[directive alloc] init];
-(BOOL)waitFor:(BOOL (^)())predicate
{
BOOL done = NO;
do
{
// Start the run loop but return after each source is handled.
SInt32 result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, YES);
// If a source explicitly stopped the run loop, or if there are no
// sources or timers, go ahead and exit.