Skip to content

Instantly share code, notes, and snippets.

View naru-jpn's full-sized avatar

Naruki Chigira naru-jpn

View GitHub Profile
@naru-jpn
naru-jpn / TimeProfiler.swift
Created November 29, 2021 07:55
Swiftプログラムの実行時間の計測 平均や標準偏差の計算
import Accelerate
class TimeProfiler {
private var results: [Float] = []
private var samples: Int = 0
private let ignores: Int
/// 現在の試行回数
var trials: Int {
results.count
@naru-jpn
naru-jpn / device.sql
Created August 31, 2021 18:25
Get iOS device name and architecture from device model.
CASE
WHEN model = 'iPhone6,1' THEN 'iPhone 5S (GSM)'
WHEN model = 'iPhone6,2' THEN 'iPhone 5S (Global)'
WHEN model = 'iPhone7,1' THEN 'iPhone 6 Plus'
WHEN model = 'iPhone7,2' THEN 'iPhone 6'
WHEN model = 'iPhone8,1' THEN 'iPhone 6s'
WHEN model = 'iPhone8,2' THEN 'iPhone 6s Plus'
WHEN model = 'iPhone8,4' THEN 'iPhone SE (GSM)'
WHEN model = 'iPhone9,1' THEN 'iPhone 7'
WHEN model = 'iPhone9,2' THEN 'iPhone 7 Plus'
@naru-jpn
naru-jpn / Device.swift
Created August 31, 2021 18:18
Get iOS device model and architecture.
import Foundation
final class Device {
enum Model: String {
case iPhone6_1 = "iPhone6,1"
case iPhone6_2 = "iPhone6,2"
case iPhone7_1 = "iPhone7,1"
case iPhone7_2 = "iPhone7,2"
case iPhone8_1 = "iPhone8,1"
case iPhone8_2 = "iPhone8,2"
@naru-jpn
naru-jpn / find_dsym.sh
Created August 31, 2021 16:46
Display all module names contained in applied appDsyms directory
files=`ls "$1"`
for uuid in ${files[@]}; do
module=`ls "$1/${uuid}/Contents/Resources/DWARF/"`
echo "${uuid:0:8}: ${module}"
done
@naru-jpn
naru-jpn / WeakReferences.swift
Last active January 31, 2017 12:01
Check behavior of unowned / weak references
//: Playground - noun: a place where people can play
import Foundation
import XCPlayground
class Executor {
// MARK: Execute stored procedure
let procedure: () -> ()
@naru-jpn
naru-jpn / NeuralNetwork.swift
Last active January 5, 2017 01:42
Neural Network in Swift with perceptron example (not yet: back propagation)
import Cocoa
/**
* Neural Network
*
* …[Cell]━[Axon]┳[Dendrite]━[Cell]━[Axon]┳…
* ┣[Dendrite]━[Cell]━[Axon]┳…
* ⋮
* ┗[Dendrite]━[Cell]━[Axon]┳…