Skip to content

Instantly share code, notes, and snippets.

View rolandoam's full-sized avatar

Rolando Abarca rolandoam

View GitHub Profile
#!/usr/bin/env ruby
if ARGV.size < 3
puts "usage: #{__FILE__} <start_no> <end_no> <output_dir> [quality]"
exit 1
end
start_no = ARGV[0].to_i
end_no = ARGV[1].to_i
output_dir = ARGV[2]
@rolandoam
rolandoam / gist:789df44adf67450f8461
Last active August 29, 2015 14:01
text buttons & actions in play-clj
(defscreen main-screen
:on-show
(fn [screen entities]
(let [ui-skin (skin "uiskin.json")
;;; this is the trick, we use a proxy (http://clojure.org/java_interop#toc25) to implement a ClickListener
cb (proxy [ClickListener] []
;;; for this object, we only care about 'clicked'
(clicked [evt x y] (println "clicked at " x y evt)))]
(update! screen :renderer (stage) :camera (orthographic))
;;; add a couple of entities to the screen. We could've used a table here, but
@rolandoam
rolandoam / Rakefile
Created July 30, 2013 01:44
Rakefile for Teensy 3.0
require "json"
require "rake/clean"
if File.exists?("project.json")
CONFIG = JSON.parse(File.read("project.json"))
else
CONFIG = {}
end
CONFIG["target"] ||= "main"
// MyDelegate.m
-(void)vungleMoviePlayed:(VGPlayData*)playData
{
// movie ad finished, get times from playData
if ([playData playedFull]) {
// give reward to user
}
}
// This is the code that initializes vungle
require 'rubygems'
require 'pp'
# you need these two gems, so `gem install` them before
require 'linode'
require 'aws-sdk'
API_KEY="YOUR_LINODE_KEY"
# create a simple domain and add a record to it
# make sure you have the env variables AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY set before running this
/**
* the simplest unit testing framework. Compatible with require.js by Rolando
* Abarca (2013) - https://gist.github.com/funkaster/5264666
*
* This is public domain, do whatever you want with this. I'm not responsible if
* something does not work the way you want. Feel free to send pull requests to
* this gist.
*
* usage:
*
@rolandoam
rolandoam / Makefile
Created March 19, 2013 19:15
makefile for both native and emscripten projects: make js # will make the js port, output a projectname.js make native # will compile the native port, output project.native make sure there are no important files named `project.*` because they will be cleaned by the `clean` target
EMSCRIPTEN_HOME = ~/Documents/inbox/emscripten
PROJECT = myproject
SOURCES = $(wildcard *.cc) $(wildcard *.c)
OBJECTS = $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(SOURCES)))
set-native:
$(eval CXX := clang -x c++)
$(eval CC := clang)
$(eval CPPFLAGS := -g -O2 -DHAS_TR1)
@rolandoam
rolandoam / compare.js
Created November 24, 2012 19:25
compare two spanish words
var spanishCharsMap = {
225: 97, // á
233: 101, // é
237: 105, // í
243: 111, // ó
250: 117, // ú
241: 110 // ñ
};
/**
@rolandoam
rolandoam / gist:4109020
Created November 19, 2012 04:43
Conversion from retain/release to smart pointers on C++

About this doc

This is a living doc and is intended to be modified!

Conversion plan

The idea of this doc is to set a minimal conversion guide to pass from the old retain - release - autorelease in cocos2d-x to a more modern, stable and cross-platform shared_ptr, auto_ptr or weak_ptr. The latter will be more friendly to the developer and also similar to what ARC provides in Objective-C

Simple case

@rolandoam
rolandoam / no_oop_for_you_in_js.mdown
Created June 25, 2012 23:57
you should not use OOP (in javascript)

You should not use OOP (in javascript)

I've been coding javascript for some time now, including interacting with several javascript VMs.

Having said that, this is just a rant about what I think could be a good approach on how to actually do things in javascript. This after looking at how other projects are dealing with it, my personal experience and finally "getting" the way javascript was meant to be used (if there's such a thing). I do not consider myself an expert in javascript, so take whatever you read here with a grain of salt and think of it as just my personal experience and of course, I'll be happy to hear what you know or your best practices around it.

The real purpose for this post is to initiate a discussion about the subject of not really using OOP when dealing with javascript, and the good way to design and think about