Skip to content

Instantly share code, notes, and snippets.

@akisute
akisute / gist:11284077
Last active August 29, 2015 14:00
This is how I implement Comparator
public static class MyComparator implements Comparator<MyClass> {
@Override
public int compare(MyClass obj1, MyClass obj2) {
int value1 = obj1.getValue();
int value2 = obj2.getValue();
// Dumb way
if (value1 == value2) {
return 0;
} else if (value1 > value2) {
@akisute
akisute / objsushi.h
Created March 31, 2014 12:53
Objective-🍣 version 1.0
//
// objsushi.h
// Objective-🍣
//
// Created by akisute on 2014/04/01.
// Copyright (c) 2014年 akisute. All rights reserved.
//
#ifndef objsushi
#define objsushi
@akisute
akisute / Podfile
Last active August 29, 2015 13:56
I'm getting hatred to this buggy tool named CocoaPods...
# CocoaPods could completely break up your MyProject.xcodeproj to the state where even CocoaPods itself can't fix it,
# (for example, losing PODS_ROOT configulations)
# if you specify some broken Podfile. Adding `target "xxx" do ~ end` structure to your Podfile might be a trigger of this.
# So here's a tip: DO NOT ADD `target` unless absolutely nessessary.
#--------------------------------------------------------------------------------
# WORKED
platform :ios, "7.0"
target "MyProject" do
@akisute
akisute / gist:9087440
Created February 19, 2014 07:16
まったく、わけがわからないよ
// OK
//UIImage *image = [UIImage imageNamed:@"bg"];
//UIImage *image = [[UIImage imageNamed:@"bg"] stretchableImageWithLeftCapWidth:0 topCapHeight:11];
//UIImage *image = [[UIImage imageNamed:@"bg"] stretchableImageWithLeftCapWidth:11 topCapHeight:11];
//UIImage *image = [[UIImage imageNamed:@"bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(11.0f, 0, 11.0f, 0)];
//UIImage *image = [[UIImage imageNamed:@"bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(11.0f, 11.0f, 11.0f, 0)];
UIImage *image = [[UIImage imageNamed:@"bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(11.0f, 0, 11.0f, 11.0f)];
// NG
//UIImage *image = [[UIImage imageNamed:@"bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(11.0f, 11.0f, 0, 0)];
//UIImage *image = [[UIImage imageNamed:@"bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(11.0f, 11.0f, 11.0f, 11.0f)];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"MY-SUPERDUPER-ID"];
[[GAI sharedInstance] ASM_setDefaultTracker:tracker];
[[GAI sharedInstance] ASM_startAutomaticSessionManagement];
// do usual stuff...
}
Process: starbound [516]
Path: /Users/USER/Library/Application Support/Steam/*/Starbound.app/Contents/MacOS/starbound
Identifier: com.chucklefish
Version: 0
Code Type: X86-64 (Native)
Parent Process: launchd [261]
Responsible: starbound [516]
User ID: 501
Date/Time: 2014-01-26 23:18:09.140 +0900
@akisute
akisute / kakkoyokusuru.rb
Created December 26, 2013 05:37
𝒶𝓀𝒾𝓈𝓊𝓉ℯ
#!/usr/bin/env ruby
# http://www.w3.org/TR/MathML2/script.html
table = {
A: 0x1D49C,
B: 0x0212C,
C: 0x1D49E,
# TODO: Add more characters here
a: 0x1D4B6,
e: 0x0212F,
>>> "{:c}".format(0x1D4B6)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: %c arg not in range(0x10000) (narrow Python build)
@akisute
akisute / gist:7869766
Last active December 30, 2015 18:49
Concept code for UITextField delegate settings
- (void)viewDidLoad
{
[super viewDidLoad];
self.textField.delegate = [AKTextFieldDelegateObject delegateObjectWithTraits:@[
[AKTextFieldDelegateTrait minLength:4],
[AKTextFieldDelegateTrait minLength:16],
[AKTextFieldDelegateTrait format:@"^[a-zA-Z0-9_]+$"]
]];
}
@akisute
akisute / gist:7869649
Created December 9, 2013 09:30
How to limit length of inputs for UITextField
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSUInteger length = textField.text.length + (string.length-range.length);
if ([textField isEqual:self.emailTextField] && length > 255) {
NSString *buffer = [textField.text stringByReplacingCharactersInRange:range withString:string];
textField.text = [buffer substringToIndex:255];
return NO;
} else if ([textField isEqual:self.passwordTextField] && length > 127) {
NSString *buffer = [textField.text stringByReplacingCharactersInRange:range withString:string];
textField.text = [buffer substringToIndex:127];