Skip to content

Instantly share code, notes, and snippets.

@akisute
akisute / Enumeration.java
Created June 6, 2014 09:51
Java enum iteration sample
public enum Suit {
Spades, Hearts, Diamonds, Clubs;
}
for (Suit suit : Suit.values()) {
System.out.println(suit.toString());
}
@akisute
akisute / NonObjCShark.swift
Last active August 29, 2015 14:02
Swim Swim Swim Lurk... to investigate how ! and ? works in normal swift class/objc attributed swift class
class NonObjCShark {
var name:NSString!
var howSwim:NSString!
init(name:NSString!, howSwim:NSString?) {
self.name = name
self.howSwim = howSwim;
}
func swim() -> String {
import Foundation
class GrayShark {
var name:String
var howSwim:String
init(name:String, howSwim:String) {
self.name = name
self.howSwim = howSwim;
}
class ExampleShark {
var name:NSString!
var howSwim:NSString!
init(name:NSString!, howSwim:NSString!) {
self.name = name
self.howSwim = howSwim;
}
func swim() -> String {
@akisute
akisute / Promise.swift
Created June 11, 2014 06:05
Promise in Swift, but completely broken in chaining. I can't just simply implement promise chaining X(
import Foundation
enum PromiseState:Int {
case Incomplete = 0
case Rejected = 1
case Resolved = 2
}
class Promise : Hashable {
@akisute
akisute / AppDelegate.m
Created June 25, 2014 08:29
Use UIPasteboard to pass around data between the main app and app extensions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Create a pasteboard, and pass some data to it
// the created pasteboard can be specified as persistent as well
UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"Widget" create:YES];
pasteboard.persistent = YES;
pasteboard.string = @"やっほー!";
return YES;
}
@akisute
akisute / SSCD01
Last active August 29, 2015 14:03
昔見かけた伝統芸能、プログラムコードは http://people.sju.edu/~jhodgson/cobol/sample.html からお借りしました
* ***************************************************************
* プログラムID SSCD01
* 機能名 S社詳細帳票出力01
* 開発担当者 株式会社akisute
* あきすてさま
* 初版 2004/06/28
*
* 変更履歴
* 2004/06/28 変更者 あきすてさま
* 初版作成。
@akisute
akisute / LocationManager.swift
Created August 2, 2014 14:23
LocationManager with PromiseKit-Swift. Well I don't like this deferred at all.
import Foundation
import CoreLocation
class LocationManager : NSObject, CLLocationManagerDelegate {
class var sharedInstance : LocationManager {
get {
struct Static {
static let instance : LocationManager = LocationManager()
- (void)viewDidLoad
{
[super viewDidLoad];
id target = [self.navigationController valueForKey:@"_cachedInteractionController"];
UIGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
[self.view addGestureRecognizer:recognizer];
// Add a dependency between your recognizer and the interactivePopGestureRecognizer
// to prevent multiple recognition, if needed.
@akisute
akisute / silent.json
Created August 12, 2014 09:38
Push Notification Payloads for iOS 7+
{"aps" : {"content-available" : 1}}