Skip to content

Instantly share code, notes, and snippets.

View modamoda's full-sized avatar

Joon Hong modamoda

View GitHub Profile
@modamoda
modamoda / scoll_detection.m
Created January 30, 2015 09:32
iOS UIScrollView: How to detect scrolling direction
// http://stackoverflow.com/a/21806997/893945
@interface MyViewController : UIViewController <UIScrollViewDelegate>
@end
@implementation MyViewController
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if([scrollView.panGestureRecognizer translationInView:scrollView.superview].y < 0) {
// up
@modamoda
modamoda / string_finder.py
Last active August 29, 2015 14:10
Objective-C non-localized point finder
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
string_finder.py
- it searches non-localzed points in Objective-C code:
-- searches string literal that contains non "visible ascii(0x20~0x7F)"
- it only searches .m files
How to use:
@modamoda
modamoda / DictionaryConvertable.m
Last active August 29, 2015 14:06
Make dictionary of properties in objective c
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface DictionaryConvertable : NSObject
- (NSDictionary *)toDictionary;
@end
// ----------
@modamoda
modamoda / git-migration.sh
Created August 29, 2014 07:01
Git migration preserving history
# http://stackoverflow.com/questions/17371150/moving-git-repository-content-to-another-repository-preserving-history
git clone NEW_REPO
cd NEW_REPO
git checkout master
git remote add old_git_remote OLD_REPO
git fetch old_git_remote
git merge old_git_remote/master
git remote rm old_git_remote
@modamoda
modamoda / Android.mk
Last active December 30, 2015 00:09
How to handle instantiated C++ object from JAVA through JNI(NDK)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := SampleCode
LOCAL_SRC_FILES := package_name_ToasterSample.cpp
include $(BUILD_SHARED_LIBRARY)
@modamoda
modamoda / callback.cpp
Created November 15, 2013 11:33
C++ callback example
void CallBackExample::getMyProfileAsync(MyProfileCallback *pfn)
{
Profile profile;
(*pfn)(&profile);
}
@modamoda
modamoda / gist:4662395
Last active December 11, 2015 21:28
UITableView: traversing all index paths
// [self.tableView eachIndexPath^(NSIndexPath *indexpath) { ... }];
@interface UITableView (Traverse)
typedef void (^iter)(NSIndexPath *indexPath);
- (void)eachIndexPath:(iter)iterBlock;
@end
@implementation UITableView (Traverse)
@modamoda
modamoda / UIView+SubView.h
Created January 10, 2013 15:15
[iOS] UIView category for finding sub-views
//
// UIView+SubView.h
//
// Created by moda
// Copyright (c) 2012년 moda. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (SubView)
@modamoda
modamoda / gist:4317827
Created December 17, 2012 12:04
one of possible solutions for https://www.facebook.com/programminglearners/posts/506757269358735 1 232 34543 4567654
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n = 5;