Skip to content

Instantly share code, notes, and snippets.

View Hokila's full-sized avatar

HOkila Jan Hokila

View GitHub Profile
# read document if you don't understand something :)
# https://github.com/yonaskolb/XcodeGen/blob/master/Docs/ProjectSpec.md
name: mazu
options:
minimumXcodeGenVersion: 2.10
usesTabs: false
indentWidth: 4
tabWidth: 4
groupSortPosition: top
@Hokila
Hokila / NotificationViewController.swift
Created July 27, 2017 15:07
Put AVPlayerLayer on UserNotification, also add play pause button
/*
See LICENSE folder for this sample’s licensing information.
Abstract:
Contains ImageContentExtension's NotificationViewController.
*/
import UIKit
import UserNotifications
import UserNotificationsUI
@Hokila
Hokila / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#define DEBUG_TRACE_LEVEL 4
#ifdef DEBUG
#if (DEBUG_TRACE_LEVEL == 0)
#define HOLog(log,...) NSLog((@"[File %s] [Function %s] [Line %d]\n" log), __FILE__,__PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#elif (DEBUG_TRACE_LEVEL == 1)
#define HOLog(log,...) NSLog((@"\n[Function %s] [Line %d]\n" log), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#elif (DEBUG_TRACE_LEVEL == 2)
#define HOLog(log,...) NSLog((@"%s\n" log), __PRETTY_FUNCTION__, ##__VA_ARGS__)
#else
@Hokila
Hokila / HD.txt
Created November 10, 2013 19:23 — forked from lexrus/HD.txt
http://devstreaming.apple.com/videos/wwdc/2013/710xfx3xn8197k4i9s2rvyb/710/710-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/202xdx2x47ezp1wein/202/202-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/200xdx2x35e1pxiinm/200/200-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/413xdx5x97itb5ek4yex3r7/413/413-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/612xax4xx65z1ervy5np1qb/612/612-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/221xex4xxohbllf4hblyngt/221/221-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/220xbx4xipaxfd1tggxuoib/220/220-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/711xcx4x8yuutk8sady6t9f/711/711-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/404xbx2xvp1eaaqonr8zokm/404/404-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/505xbx4xrgmhwby4oiwkrpp/505/505-HD.mov?dl=1
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
if([[userInfo objectForKey:@"aps"] objectForKey:@"alert"]!=NULL){
NSString *alertbody = [[userInfo objectForKey:@"aps"] objectForKey:@"alert"];
application.applicationIconBadgeNumber = application.applicationIconBadgeNumber+1;
}
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
NSString *token = [NSString stringWithFormat:@"%@", [deviceToken description]];
token = [token stringByReplacingOccurrencesOfString:@"<" withString:@""];//去左箭號
token = [token stringByReplacingOccurrencesOfString:@">" withString:@""];//去右鍵號
token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];//去空白
//把拿到的deviceToken去頭去尾後 拿去註冊push
[self registerPushServer:self.phone_id :token ];
//跟APNS說我要用推播
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
NSString* urlStr = @"https://maps.google.com.tw/maps?q=加油站";
NSURL *url = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.gasWebView loadRequest:request];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Converting RGBA color for use with UIColor
UIColor *colorFromRgba = [UIColor colorWithRed:23/255.0f green:45/255.0f blue:145/255.0f alpha:1];
NSLog(@"converted rgba color is: %@", colorFromRgba);
[self.window makeKeyAndVisible];