Skip to content

Instantly share code, notes, and snippets.

@y-takagi
y-takagi / typescript-extension.md
Last active August 10, 2020 02:39
Implement extention method w/ typescript.

Implement extention method w/ typescript.

Array

// array.ext.ts

declare global {
  interface Array<T> {
 flatten(): Array;
@y-takagi
y-takagi / install-emacs.md
Last active December 7, 2021 06:51
Install emacs to macOS with options.

Install emacs to macOS with options.

Homebrew

Use homebrew formula of emacs head.

https://github.com/d12frosted/homebrew-emacs-plus

brew tap d12frosted/emacs-plus
brew install emacs-plus@28 # Change the 28 part to different version you want to install.
@y-takagi
y-takagi / promisekit.org
Last active January 7, 2017 20:37
PromiseKit Guide

PromiseKit Guide (v4.1.0)

PromiseKit の使い方。

Create Promise

enum SampleError: Error {
 case error
}
@y-takagi
y-takagi / Swift Guide (v3.0).org
Last active July 25, 2020 03:38
Swift Guide (v3.0)

Swift Guide (v3.0)

Comment

1行コメント

// this is a comment

複数行コメント

@y-takagi
y-takagi / docker_cookbook.org
Last active November 4, 2016 02:02
Usefull recipes when using docker

Docker Cookbook

環境は以下。

Host OSDocker version
Ubuntu 16.041.12.3

1. Move storage directory

Dockerは、imageやその他データをデフォルトでは /var/lib/docker に格納する。

@y-takagi
y-takagi / migrate_ecr_region.sh
Created August 24, 2016 02:18
ECRのリージョン移行
#!/bin/bash
#
# 前準備として、移行先に各イメージのレポジトリを作成しておく必要あり。
# $from、$to、$aws_account_id、$images は適宜変更する。
#
set -e
from="us-east-1"
to="ap-northeast-1"
aws_account_id=""
@y-takagi
y-takagi / rxswift.org
Last active November 3, 2016 12:38
Introduction to ReactiveX/RxSwift

Introduction to ReactiveX/RxSwift

RxSwiftは、ReactiveX(Rx)のswift実装である。この投稿ではRxの概要をRxSwiftを用いて解説する。

Rxを簡単に説明すると、下記のものを組み合わせたライブラリである。

Rx = Observable + Operators + Scheduler

基本的にはObserverパターンの拡張であり、非同期データストリームであるObservableに対して

@y-takagi
y-takagi / DOCUMENT.md
Created July 1, 2016 03:07
iOS10とXcode8の気になった機能をリストアップ
@y-takagi
y-takagi / DOCUMENT.md
Last active April 29, 2024 16:36
iOSでデータを永続化する方法

How to save data in iOS

この投稿では、iOSのファイルシステムについて理解し、データを永続化(iCloud含む)する方法を紹介する。尚、サンプルコードは動かない可能性もあるので参考程度にして下さい。

iOS File System

アプリがファイルシステムとやり取り出来る場所は、ほぼアプリのサンドボックス内のディレクトリに制限されている。新しいアプリがインストールされる際、インストーラーはサンドボックス内に複数のコンテナを作成し、図1に示す構成をとる。各コンテナには役割があり、Bundle Containerはアプリのバンドルを保持し、Data Containerはアプリとユーザ両方のデータを保持する。Data Containerは用途毎に、さらに複数のディレクトリに分けられる。アプリは、例えばiCloud Containerのように、実行時に追加のコンテナへのアクセスをリクエストすることもある。

IMG_0017_RESIZE.png

図1. An iOS app operating within its own sandbox

@y-takagi
y-takagi / Dockerfile
Last active June 30, 2016 04:50
Data Volume の一例
FROM image
COPY hoge.txt /tmp
VOLUME /tmp