Skip to content

Instantly share code, notes, and snippets.

View toughrogrammer's full-sized avatar

Juhong Jung toughrogrammer

View GitHub Profile
function clone(object)
local lookup_table = {}
local function _copy(object)
if type(object) ~= "table" then
return object
elseif lookup_table[object] then
return lookup_table[object]
end
local new_table = {}
lookup_table[object] = new_table
@toughrogrammer
toughrogrammer / PanZoomLayer.cpp
Last active January 3, 2016 23:29
GrowingDever's PanZoomLayer :pIf it is useful to you, improve this and share please!
#include "PanZoomLayer.h"
PanZoomLayer::PanZoomLayer()
{
}
PanZoomLayer::~PanZoomLayer()
@toughrogrammer
toughrogrammer / usage-myanimation
Last active December 28, 2015 22:59
Usage of my cocos2d-x sprite animation class
// Create animatino class and run it
CCNode *anim = MyAnimation::create( "gamescene/star_sprite_animation.json" );
anim->PlayWithSequence( "eaten" );
@toughrogrammer
toughrogrammer / gist:6155275
Last active December 20, 2015 15:38
Text length
/**
* Delegate method called before the text has been changed.
* @param textField The text field containing the text.
* @param range The range of characters to be replaced.
* @param string The replacement string.
* @return YES if the specified text range should be replaced; otherwise, NO to keep the old text.
*/
- (BOOL)textField:(UITextField *) textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSUInteger oldLength = [textField.text lengthOfBytesUsingEncoding:(0x80000000 + kCFStringEncodingDOSKorean)];
@toughrogrammer
toughrogrammer / mergesort
Last active December 18, 2015 03:49
Is it mergesort algorithm?
void init( int arr[], int size, int value )
{
int i;
for( i=0; i<size; i++ )
arr[i] = value;
}
void merge( int arr[], int leftstart, int leftend, int rightstart, int rightend )
{
int* tmp = new int[ rightend - leftstart + 1];
@toughrogrammer
toughrogrammer / gist:5330010
Last active December 15, 2015 21:59
시그마와 For문 비교입니다. 아래 소스코드의 sum 값은 시그마 i=0->4와 같습니다.
#include <stdio.h>
int main()
{
int sum = 0;
int i;
for( i=0; i<5; i++ )
{
sum = sum + i;