Skip to content

Instantly share code, notes, and snippets.

View ochim's full-sized avatar

munehiro ochi ochim

View GitHub Profile
@Pooh3Mobi
Pooh3Mobi / LifeCycleObserveableLogger.kt
Last active April 23, 2021 11:20
LifeCycleObserveableLogger
import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
object IndentProvider {
private var depth = 0
private const val SPACE = " "
import UIKit
extension UIScrollView {
struct DefaultProperty {
let contentOffset: CGPoint
let contentSize: CGSize
let contentInset: UIEdgeInsets
let zoomScale: CGFloat
}
@xhiroga
xhiroga / kotlinfest2019.md
Last active January 3, 2020 04:19
Kotlin Fest 2019 登壇資料まとめ
@brennanMKE
brennanMKE / directoryExistsAtPath.swift
Created April 20, 2017 22:23
Directory Exists at Path in Swift
fileprivate func directoryExistsAtPath(_ path: String) -> Bool {
var isDirectory = ObjCBool(true)
let exists = FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory)
return exists && isDirectory.boolValue
}
@re-fort
re-fort / kachidoki_elevator.cc
Last active February 24, 2017 11:06 — forked from remore/kachidoki_elevator.cc
(1: 最適化問題) 下記パラメータのままでElevator::tick()のみを最適化して平均待ち人数を最小化する / (2: 並列化問題) 以下のプログラムをマルチスレッドで動作させると何倍早くなるか実装して検証する / (3: チューニング問題)並列化以外の方法で本プログラムの実行時間を短縮するためにどのような改修を加えるとよいか考察する
#include <iostream>
#include <iomanip>
#include <random>
#include <unistd.h>
using namespace std;
const int MAX_FLOOR = 14;
const int ELEVATOR_COUNT = 4;
const int RAISING_PROBABILITY = 10;
@jkubecki
jkubecki / ExportKindle.js
Last active February 25, 2024 00:45
Amazon Kindle Export
// The following data should be run in the console while viewing the page https://read.amazon.com/
// It will export a CSV file called "download" which can (and should) be renamed with a .csv extension
var db = openDatabase('K4W', '3', 'thedatabase', 1024 * 1024);
getAmazonCsv = function() {
// Set header for CSV export line - change this if you change the fields used
var csvData = "ASIN,Title,Authors,PurchaseDate\n";
db.transaction(function(tx) {
@y-takagi
y-takagi / DOCUMENT.md
Last active July 6, 2023 05:27
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

@KentarouKanno
KentarouKanno / WKWebView.md
Last active March 30, 2023 17:24
WKWebView

WKWebView

import UIKit
import WebKit

class ViewController: UIViewController, WKNavigationDelegate {
    
    var wkWebView: WKWebView!
    let observerKeyName = ["estimatedProgress", "loading", "title", "URL", "hasOnlySecureContent", "canGoBack", "canGoForward"]
@aphlysia
aphlysia / stfuawsc_itg_advent2014_4_conda.md
Last active June 16, 2023 01:05
conda で python の環境つくり

これは stfuawsc_itg Advent Calendar 2014 4日目の記事です。

プログラミングをしていると、いろいろなバージョンの環境を行ったり来たりしたくなることがあります。たとえば言語処理は python 2 へ nltk を入れてやりたい。シミュレーションは python 3 へ numpy 入れてやりたいとか。
そういうふうに言語やモジュールのバージョンをいろいろ組合せた環境を気軽に切り替えられると便利です。
実際そういうことを可能にするツールはたくさんあります。virtualenv, pyenv など。
ここで紹介する conda というツールもその1つです。
virtualenv などでは、モジュールを入れるときは通常の python の流儀でインストールするのですが、インストールがうまくいかないというのはよくあることです。conda ではあらかじめビルドされたものを入れるので、楽です。もちろん conda に用意されていないモジュールもありますが、そういうのは pip 等通常の方法で入れて共存できます。

ではさっそく conda で python の環境を作る方法です。

@shinyaohira
shinyaohira / App States and Multitasking.md
Last active October 5, 2023 07:57
アプリケーションの状態とマルチタスキング

全体的に簡略化し、必要と思われる部分を抜粋しました。

  • Not running

    アプリは起動されていないか、実行されていたけれどもシステムによって終了されています。

  • Inactive