Skip to content

Instantly share code, notes, and snippets.

Avatar

Satoshi Namai ainame

View GitHub Profile
View rubocop_todo_yml_parser.rb
require 'yaml'
cops = File.read('.rubocop_todo.yml')
.split("\n\n")
.drop(1)
.map {
{
count: _1.match(/Offense count: (\d+)/).captures[0].to_i,
yaml: YAML.load(_1),
auto_correct: _1.match(/Cop supports --auto-correct/) != nil
}
@ainame
ainame / Mappable.swift
Created November 7, 2019 01:23
NSManagedObjectから任意のモデルに相互にマップしあう定義をプロトコル化するとCoreData Wrapper書くのに捗りそう
View Mappable.swift
import Foundation
import CoreData
protocol NSManagedObjectMappable: NSManagedObject where MapFrom.MapFrom == Self {
associatedtype MapFrom: MappableFromNSManagedObject
static func mappedObject(from object: MapFrom, in context: NSManagedObjectContext) -> Self
}
enum MappingError: Error {
case missingNonOptionalValue(String)
View test.swift
import Darwin
let string = "hello world"
var array = [UInt8]()
string.withCString { ptr in
print("strlen: \(strlen(ptr))")
let length = strlen(ptr)
var currentPtr = ptr
@ainame
ainame / string-api-changes.swift
Last active June 6, 2017 17:39
Is this a bug on the Swift4?
View string-api-changes.swift
import Foundation
let array: [String?] = ["a", "b", "c", "e"]
print(array) // => [Optional("a"), Optional("b"), Optional("c"), Optional("e")]
let strings = array.flatMap { $0! }
print(type(of: strings)) // => Array<Character>
@ainame
ainame / update-xcode-plugin
Created December 10, 2015 03:12 — forked from kakikubo/update-xcode-plugin
Xcodeをバージョンアップした際に、プラグインも新バージョン側に適用させる
View update-xcode-plugin
#!/usr/bin/env sh
UUID=$(defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID)
echo Xcode DVTPlugInCompatibilityUUID is $UUID
for MyPlugin in ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/*
do
UUIDs=$(defaults read "$MyPlugin"/Contents/Info DVTPlugInCompatibilityUUIDs)
echo $MyPlugin
if echo "${UUIDs[@]}" | grep -w "$UUID" &>/dev/null; then
echo "The plug-in's UUIDs has contained the Xcode's UUID."
else
@ainame
ainame / matome.md
Last active October 4, 2017 08:16
井戸端iOS飯で過去に見た動画まとめ
View matome.md

井戸端iOS飯

とは?

井戸端iOS飯とは、昼休み1時間+MTG分の30分の計1時間30分を利用して、 NBFオフィスのコラボのプロジェクターとスクリーンを利用して、 最新のスマホアプリ開発技術に関する動画を見ながらご飯を食べて、 交流する場です。

ぜひお気軽にご参加ください。

@ainame
ainame / identity.rb
Last active September 17, 2015 13:31
.idがidenitityを提供するということを示すmixinモジュールの名前どれが良いか
View identity.rb
# 1
class Coriander
include MyApp::Entity::HasId
end
# 2
class Coriander
include MyApp::Entity::Identifiable
end
@ainame
ainame / chain_query.rb
Created August 27, 2015 17:55
ChainQuery allow you to build query by method chains.
View chain_query.rb
class ChainQuery
def initialize(init_value)
@init_value = init_value
@filters = []
end
def add_filter(&block)
@filters << block
self
end
View gist:26664acc3ad08372b02d

住所

〒 153-0064 東京都目黒区下目黒5-11-24 シェアハウス(中村・矢口・荻原宅)

行き方

best practice

@ainame
ainame / file0.txt
Last active June 20, 2016 01:19
ActiveRecord::Enumで陥りがちなミスを避ける ref: http://qiita.com/ainame/items/a097558e74bf7d5087b9
View file0.txt
class NotifyEndpoint
enum platform: [:apns, :gcm]
end