Skip to content

Instantly share code, notes, and snippets.

- (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...
}
@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)];
@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 / 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 / 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) {
public int getCryptoTypeDumb() {
// With Plain Java
List<Network> networkList = new ArrayList(mNetworkSet);
Collections.sort(networkList, NetworkComparators.CRYPTOTYPE_WEAKEST_TO_STRONGEST);
return networkList.get(0).getCryptoType();
}
public int getCryptoType() {
// With Google Guava
return Ordering.from(NetworkComparators.CRYPTOTYPE_WEAKEST_TO_STRONGEST).min(mNetworkSet).getCryptoType();
Initialize engine version: 4.3.3f1 (c8ca9b6b9936)
GfxDevice: creating device client; threaded=1
OpenGL:
Version: OpenGL 2.1 [2.1 NVIDIA-8.24.9 310.40.25f01]
Renderer: NVIDIA GeForce GTX 680MX OpenGL Engine
Vendor: NVIDIA Corporation
VRAM: 2048 MB
Extensions: GL_ARB_color_buffer_float GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_draw_elements_base_vertex GL_ARB_draw_instanced GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_imaging GL_ARB_instanced_arrays GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_provoking_vertex GL_ARB_seamless_cube_map GL_ARB_shader_objects GL_ARB_shader_texture_lod GL_ARB_shading_language_100 GL_ARB_shadow GL_ARB_sync GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_c
@akisute
akisute / MyPlayground.swift
Last active August 29, 2015 14:02
Playing around with Swift
import Foundation
var l = [
"abesi",
"hidebu",
"tawaba",
]
var m = [
"abesi": 1,
@akisute
akisute / example1.swift
Last active August 29, 2015 14:02
Several disappointing Swift code snippets...
class MyClass {
var someValue:Int
func someMethod() -> Int {
return 42
}
var callback:(Int) -> (Void) = {(value:Int) -> (Void) in
// Using self within a closure owned by self makes reference loop
self.someValue = self.someMethod() + value
}
@akisute
akisute / EnumerationForEnum.swift
Created June 6, 2014 09:44
Enumeration for enum classes in Swift.
enum Rank:Int {
case Ace = 1
case Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten
case Jack, Queen, King
// Here's an undocumented trick: How to enumerate enums using Generator!
// I wish I could use yield though ;(
class EnumGenerator:Generator {
var i = 1
func next() -> Rank? {