Skip to content

Instantly share code, notes, and snippets.

View HituziANDO's full-sized avatar

Hituzi Ando HituziANDO

View GitHub Profile
@HituziANDO
HituziANDO / UnitySafeArea.cs
Created December 6, 2017 03:08
[Unity Script] safeAreaInsets of iPhoneX sample code
using UnityEngine;
public struct EdgeInsets {
public float Top { get; }
public float Left { get; }
public float Bottom { get; }
public float Right { get; }
public EdgeInsets(float top, float left, float bottom, float right) {
@HituziANDO
HituziANDO / TimeUtils.cs
Created November 14, 2017 06:26
DateTime <-> UnixTime(long) 変換クラス
using System;
namespace MyApplication {
public class TimeUtils {
private static DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0);
private TimeUtils() {
}
@HituziANDO
HituziANDO / JsonArray.cs
Created November 14, 2017 04:16
Unity JsonUtilityでルートが配列なデータを扱いやすくするクラス
using UnityEngine;
using System;
using System.Collections.Generic;
namespace MyApplication
{
/// <summary>
/// JsonUtilityはルートが配列の場合は扱えないため、オブジェクトでラップするクラスです。
///
/// { "array": [ 指定した配列要素 ] }
@HituziANDO
HituziANDO / IPAddress.h
Created October 26, 2017 03:05
[Obj-C] Get IP address.
//
// IPAddress.h
//
// Created by Hituzi Ando on 2017/10/26.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@HituziANDO
HituziANDO / sample.m
Created September 6, 2017 03:03
iOS8以上か判定するプリプロセッサ
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
#endif
@HituziANDO
HituziANDO / jquery.deferred-all.js
Last active April 6, 2016 08:15
jQuery.whenにQ.allのように配列でDeferredを渡す方法
/**
* jQuery.whenにQ.allのように配列でDeferredを渡す関数
*
* @param deferredList Array of jQuery.Deferred object
* @returns jQuery.Promise object
*/
function $all(deferredList) {
return $.when.apply(null, deferredList);
}
/**
* @version 1.0.4
* @require jQuery 1.0+
*/
(function ($) {
/**
* @param opts
* disable: trueならばスクロールを無効にする
* duration: 'fast','slow'またはミリ秒
* offsetTop: ビューより上部の余白分
@HituziANDO
HituziANDO / iOS_StatusBar
Last active August 29, 2015 14:15
iOSのステータスバースタイル変更
// info.plistの"View controller-based status bar appearance"をYESにする
// 各ViewControllerで下記のように実装する
// "View controller-based status bar appearance"をNOにした場合はinfo.plistの"Status bar style"が全ViewControllerに適用される
// "View controller-based status bar appearance"をinfo.plistに追加していない場合は変更は適用されない
- (void) viewDidLoad {
[super viewDidLoad];
// 変更を通知
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
[self setNeedsStatusBarAppearanceUpdate];
@HituziANDO
HituziANDO / selector.html
Last active December 21, 2015 01:59
HTMLでプルダウンリストの選択した値の取得方法をよく忘れてしまうのでメモ。
<select id="selXxx" onchange="onChange(this)">
<option value="hoge" selected>hoge</option>
<option value="foo">foo</option>
<option value="bar">bar</option>
</select>
<script>
function onChange (selector) {
var val = selector.options[selector.selectedIndex].value;
if (val == "hoge") {
@HituziANDO
HituziANDO / prevent.css
Created August 14, 2013 15:10
HTML長押しで出てくるAlertView等を封印します。
* {
/* prevent callout to copy image, etc when tap to hold */
-webkit-touch-callout: none;
/* prevent webkit from resizing text to fit */
-webkit-text-size-adjust: none;
/* make transparent link selection, adjust last value opacity 0 to 1.0 */
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
/* prevent copy paste, to allow, change 'none' to 'text' */
-webkit-user-select: none;
}