-
名前(任意)
- xxxxxx xxxxxxx
-
Twitter or Facebookのアカウント or HN等
-
@xxxxxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Darwin | |
let string = "hello world" | |
var array = [UInt8]() | |
string.withCString { ptr in | |
print("strlen: \(strlen(ptr))") | |
let length = strlen(ptr) | |
var currentPtr = ptr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. for, whileを使わずにeachを使う | |
array = [1,2,3,4,5] | |
array.each do |e| | |
print e | |
end | |
#=> 12345 | |
# テキストファイルを一気に読み込んで, | |
# 1行ごとにイテレート | |
textfile = File.open("a.txt").read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun newline-or-open-line () | |
"newline-or-openline is a new command for merging C-m and C-o" | |
(interactive) | |
(let ((string-exists-before-cursor (string-match "[^\\\s\\\n\\\t]" (buffer-substring (point-at-bol) (point)))) | |
(string-exists-after-cursor (string-match "[^\\\s\\\n\\\t]" (buffer-substring (point) (point-at-eol))))) | |
(cond ((or (eolp) | |
(not string-exists-after-cursor) | |
(and string-exists-before-cursor string-exists-after-cursor)) | |
(progn (princ 1) (newline) (indent-according-to-mode))) | |
(t (progn (princ 2) (open-line 1) (indent-according-to-mode)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NotifyEndpoint | |
enum platform: [:apns, :gcm] | |
end |
NewerOlder