Skip to content

Instantly share code, notes, and snippets.

View tolmasky's full-sized avatar

Francisco Ryan Tolmasky I tolmasky

View GitHub Profile
using UnityEngine;
using System.Collections;
public class TestBehavior : MonoBehaviour
{
public GameObject whatever;
// Use this for initialization
void Start ()
{
using System.Runtime.InteropServices;
namespace PlaygroundTheory
{
public static class App
{
#if UNITY_IPHONE && !UNITY_EDITOR
@tolmasky
tolmasky / static strategy 1
Created July 22, 2014 19:26
static strategy 1
// Strategy 1: No typecast magic
//
// To compile and run:
//
// $ g++ -W -Wall -Wextra -pedantic -std=c++0x -o static static.cpp && ./static
#include <string>
#include <iostream>
@tolmasky
tolmasky / goal.h
Created July 25, 2014 01:25
C static strategy
#include <stdlib.h>
#include <stdio.h>
#include <regex.h>
#include <string.h>
// We still need g()()()()("al") to pass initial compilation,
// so have it evaluate to either just "g" or "f". We then define
// these as constants so they serve as type placeholders. This way
// double x = g()()()("al") will appropriately complain.
//===========================================================================
//
// Parsing Expression Grammar for Java 1.6 for Mouse 1.1 - 1.6.
// Based on Chapters 3 and 18 of Java Language Specification, Third Edition,
// at http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html.
//
//---------------------------------------------------------------------------
//
// Copyright (C) 2006, 2009, 2010, 2011, 2013
@tolmasky
tolmasky / gist:39ea427805e3213f34c1
Created September 10, 2014 21:00
Array concat as function
// [A0, A1, ..., AN-1]
// Code(X) = 2^N - 1 + Sum(0, N - 1, Xi * 2^i)
// [B0, B1, ..., BM-1]
// Concat(A, B) = 2 ^ [floor(lg (N + 1)) + floor(lg (M + 1))] - 1 +
// Code(A) - (2 ^ N - 1) + Code(B) - (2 ^ M - 1)
// graph: http://www.wolframalpha.com/input/?i=plot+2+%5E+%28floor%28lg2+%28x+%2B+1%29%29+%2B+floor%28lg2+%28y+%2B+1%29%29%29+-+1+%2B+%28x+-+%282+%5E+floor%28lg2+%28x+%2B+1%29%29+-+1%29%29+*+%282+%5E+floor%28lg2+%28y+%2B+1%29%29%29+%2B+%28y+-+%282+%5E+floor%28lg2+%28y+%2B+1%29%29+-+1%29%29%2C+x%3D0..3%2C+y%3D0..3
var _ = require("underscore");
@tolmasky
tolmasky / polymer
Created September 15, 2014 19:25
polymer question
<!--
What I want is for the following:
<father name = "John">
<child name = "Bob">likes lolipops</child>
<child name = "Jessica">likes computers</child>
</father>
to generate:
---
var Reduction = React.createClass(
{
render: function() {
var self = this;
return <div><Child isParentMounted = { function() { return self.isMounted(); } } /></div>;
},
componentDidMount: function() { console.log("actually mounted."); }
});
var Child = React.createClass(
var everything = React.createElement(
{
render: return <html>
<body>
<mycomponent model = { model } />
<script>
{
"model = " + JSON.stringify(modle) + ";" +
"React.renderComponent(<everything />), document);"
}
function fromJS(anObject)
{
var objectsToReferences = new Map();
return fromJS(anObject);
function fromJS(anObject)
{
if (objectsToReferences.has(anObject))
return objectsToReferences.get(anObject);