Skip to content

Instantly share code, notes, and snippets.

View agiletalk's full-sized avatar

chanju Jeon agiletalk

View GitHub Profile
@agiletalk
agiletalk / gist:7981343
Created December 16, 2013 02:01
Tumblr에 Pocket Button 설치하기 http://getpocket.com/publisher/button
<div class="pocket-button">
<a href="https://getpocket.com/save" class="pocket-btn" data-lang="en"
data-save-url="{Permalink}"
data-pocket-count="none">Pocket</a>
<script type="text/javascript">!function(d,i){if(!d.getElementById(i)){var j=d.createElement("script");j.id=i;j.src="https://widgets.getpocket.com/v1/j/btn.js?v=1";var w=d.getElementById(i);d.body.appendChild(j);}}(document,"pocket-btn-js");</script>
</div>
@agiletalk
agiletalk / .gitattributes
Created November 8, 2013 19:57
project.pbxproj 충돌 해결
*.pbxproj binary merge=union
@agiletalk
agiletalk / gist:7261108
Created November 1, 2013 04:55
iOS에서 사용자 로케일 순으로 정렬하기
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"key_name" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) {
NSStringCompareOptions comparisonOptions = NSCaseInsensitiveSearch | NSNumericSearch | NSWidthInsensitiveSearch | NSForcedOrderingSearch;
NSRange stringRange = NSMakeRange(0, ((NSString *)obj1).length);
return [(NSString *)obj1 compare:(NSString *)obj2 options:comparisonOptions range:stringRange locale:[NSLocale autoupdatingCurrentLocale]];
}];
sortedArray = [[NSMutableArray alloc] initWithArray:[arrayFromSQLite sortedArrayUsingDescriptors:@[sortDescriptor]]];
@agiletalk
agiletalk / NSLog2File.m
Created June 10, 2013 10:26
NSLog To File
@implementation UIApplication (Logging)
+ (void)redirectConsoleLogToDocumentFolder:(NSString *)filename
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *logPath = [documentsDirectory stringByAppendingPathComponent:filename];
freopen([logPath cStringUsingEncoding:NSASCIIStringEncoding], "a+", stderr);
}
@agiletalk
agiletalk / UIImage
Created May 13, 2013 08:18
How to change the color of an UIImage
+ (UIImage *)imageNamed:(NSString *)name withColor:(UIColor *)color;
{
UIImage *image = [UIImage imageNamed:name];
CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClipToMask(context, rect, image.CGImage);
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
@agiletalk
agiletalk / ToastTest.java
Created May 24, 2011 17:49
[예제] Toast 객체 사용하기
package org.catchabug.ToastTest;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
public class ToastTest extends Activity {
Toast mToast = null;
int count;
@agiletalk
agiletalk / DrawPath.java
Created May 24, 2011 17:11
[예제] Path 객체 그리기
public void onDraw(Canvas canvas) {
Path path = new Path();
canvas.drawColor(Color.WHITE);
Paint Pnt = new Paint();
Pnt.setStrokeWidth(5);
Pnt.setColor(Color.RED);
Pnt.setStyle(Paint.Style.STROKE);
// 원, 사각형을 패스로 정의한 후 출력
@agiletalk
agiletalk / DrawText.java
Created May 24, 2011 16:42
[예제] Text 객체 그리기
public void onDraw(Canvas canvas) {
Paint Pnt = new Paint();
canvas.drawColor(Color.WHITE);
String str = "Made in Korea";
char[] arCh = {'a', 'b', 'c'};
// 기본 문자열 출력. 안티 알리아싱을 적용했다.
Pnt.setAntiAlias(true);
Pnt.setColor(Color.BLACK);
canvas.drawText(str, 10, 10, Pnt);
//
// UITextViewTutorialViewController.h
// UITextViewTutorial
//
// Created by chanju Jeon on 11. 5. 4..
// Copyright 2011 Talk on :Play. All rights reserved.
//
#import <UIKit/UIKit.h>
@agiletalk
agiletalk / DrawBitmap.java
Created April 27, 2011 11:39
[예제] Bitmap 객체 그리기
public void onDraw(Canvas canvas) {
Paint Pnt = new Paint();
canvas.drawColor(Color.WHITE);
/* 원론적인 방법
Resources r=getResources();
BitmapDrawable bd=(BitmapDrawable)r.getDrawable(R.drawable.eighty8);
Bitmap bit=bd.getBitmap();
//*/