Skip to content

Instantly share code, notes, and snippets.

View rolandoam's full-sized avatar

Rolando Abarca rolandoam

View GitHub Profile
@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 / nsdictionary_to_json.rb
Created June 3, 2012 04:10
NSDictionary to JSON with macruby
framework 'foundation'
require 'json'
dict = NSDictionary.dictionaryWithContentsOfFile("/path/to/your/dict.plist")
File.open("/path/to/your/file.json", "w+") { |f| f.write JSON.generate(dict) }
# pretty print:
#
# File.open("/path/to/your/file.json", "w+") { |f| f.write JSON.generate(dict, :indent => "\t", :object_nl => "\n") }
@rolandoam
rolandoam / gist:2440784
Created April 22, 2012 01:58
enable webgl on embedded WebViews
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WebKitWebGLEnabled"];
[[NSUserDefaults standardUserDefaults] synchronize];
@rolandoam
rolandoam / SectionalMenu.h
Created November 4, 2010 18:42
SectionalMenu.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
@interface SectionalButton : CCSprite
{
id target_;
CCArray *selectors_;
CCArray *sections_;
CCArray *sectionsEnabled_;
CCArray *sectionsData_;
#!/usr/bin/ruby
GROWLNOTIFY = "/Users/rolando/Applications/growlnotify"
ALERT_SOUND = "/Users/rolando/Documents/GFF/SFX/alert_35.wav"
class Fixnum
def minutes
self * 60
end
end
@rolandoam
rolandoam / MultilineBitmapFontAtlas.m
Created April 28, 2010 14:32
multiline BitmapFontAtlas for Cocos2D-iPhone
/*
* adapted from http://www.cocos2d-iphone.org/forum/topic/207
*
* Returns a CCNode with the string. It splits on new lines and returns the length of the final node.
* The length parameter is there to know the final length of the node (pass nil if you don't need it).
*
*
* call it this way:
*
* int length;
@rolandoam
rolandoam / GFFParallaxNode.h
Created December 14, 2009 16:22
GFFParallaxNode
//
// GFFParallaxNode.h
//
// Created by Rolando Abarca on 12/14/09.
//
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#define MAX_PARALLAX_CHILDREN 25
@rolandoam
rolandoam / emailgateway.rb
Created June 9, 2009 16:44
cocos2d email gateway
#!/usr/bin/env ruby
# Copyright (c) 2009, Rolando Abarca M.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@rolandoam
rolandoam / bbpress_xmlrpc.rb
Created June 8, 2009 00:08
testing xmlrpc on cocos2d forum
# xmlrpc is stdlib
require 'xmlrpc/client'
require 'pp'
user = "user"
pass = "mypass"
url = "http://www.cocos2d-iphone.com/forum/xmlrpc.php"
server = XMLRPC::Client.new2(url)
# note: this call works even if authentication fails!
#!/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]