Skip to content

Instantly share code, notes, and snippets.

View yuseinishiyama's full-sized avatar
🙂
Feeling lost and content

Yusei Nishiyama yuseinishiyama

🙂
Feeling lost and content
View GitHub Profile
@yuseinishiyama
yuseinishiyama / rot13Reader.go
Created January 30, 2019 21:10
A Tour of Go: rot13Reader
// https://tour.golang.org/methods/23
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
public protocol DefaultValueProviding {
static var defaultValue: Self { get }
}
extension String: DefaultValueProviding {
public static var defaultValue: String { return "" }
}
extension Int: DefaultValueProviding {
public static var defaultValue: Int { return 0 }
//
// NSObject+Blocks.h
// Filemator
//
// Created by Zachary Waldowski on 4/12/11.
// Copyright 2011 Dizzy Technology. All rights reserved.
//
@interface NSObject (Blocks)
@yuseinishiyama
yuseinishiyama / force_load
Last active August 29, 2015 13:56
-ObjCを使わずにビルドする。
-lxml2 -force_load\ "${PROJECT_DIR}/Dependencies/GoogleAnalyticsServicesiOS_3.03a/libGoogleAnalyticsServices.a" -force_load ${BUILT_PRODUCTS_DIR}/libGMGridView.a -force_load ${BUILT_PRODUCTS_DIR}/libfacebook_ios_sdk.a
@yuseinishiyama
yuseinishiyama / imageForNavigationBar
Last active August 29, 2015 13:56
素材を用意せずに、単色のナビゲーションバーを設定する方法。
+ (UIImage *)imageForNavigationBar
{
/*
* 1x44、最下部のドットが灰色でその他は白色の画像を生成する。
*/
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 44.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
@yuseinishiyama
yuseinishiyama / FetchLatestAppVersionSnippets
Last active January 3, 2016 13:09
Fetch latest app version from the app store.
+ (NSString *)applicationVersion {
return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
}
+ (void)showNeedUpdateAlertIfNeeded
{
[self getLatestAppVersionAsynchronousWithCompletionBlock:^(NSString *latestAppVersion) {
if ([latestAppVersion compare:[ApplicationInformation applicationVersion] options:NSNumericSearch] == NSOrderedDescending) {
dispatch_async(dispatch_get_main_queue(), ^{
// Show alert etc...
@yuseinishiyama
yuseinishiyama / DontDestroyObject.cs
Created January 17, 2014 02:42
Attaching this script to a object, the object survives in all scenes. (For Unity3d)
using UnityEngine;
using System.Collections;
public class DontDestroyObject : MonoBehaviour
{
static DontDestroyObject instance;
void Awake ()
{
if (!instance) {
@yuseinishiyama
yuseinishiyama / Seeker.cs
Created January 17, 2014 02:34
For syncing events with audio. (For Unity3d)
using UnityEngine;
using System.Collections;
[AddComponentMenu("Scripts/BGM/Seeker")]
public class Seeker : MonoBehaviour
{
public float seekTime {
get {
return isSeeking ? (float)AudioSettings.dspTime - startTimeByDspTime : 0;
}
@yuseinishiyama
yuseinishiyama / BGMManager.cs
Last active January 3, 2016 13:09
Manage background music. (For Unity3d)
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[AddComponentMenu("Scripts/BGM/BGMManager")]
public class BGMManager : MonoBehaviour
{
AudioSource audioSource;
public List<AudioClip> audioClips ;