Skip to content

Instantly share code, notes, and snippets.

@es-kumagai
es-kumagai / CodePiece.swift
Created March 29, 2016 12:59
先ほどの自分の発表で使ったコード、とは若干違うところもありますけど、とりあえず資料を書きながら作ったコードを切り出しました。 #__swift__ #CodePiece
protocol Movable {
associatedtype Unit
func moved(x x:Unit, y:Unit) -> Self
func movedHorizontal(x:Unit) -> Self
func movedVertical(y:Unit) -> Self
}
struct Location {
@feelingplace
feelingplace / Regexp.swift
Last active March 11, 2016 13:06 — forked from takafumir/Regexp.swift
Swift utility class for regular expression
import Foundation
class Regexp {
let internalRegexp: NSRegularExpression
let pattern: String
init(_ pattern: String) {
self.pattern = pattern
do {
self.internalRegexp = try NSRegularExpression(pattern: pattern, options: NSRegularExpressionOptions.CaseInsensitive)
@es-kumagai
es-kumagai / CodePiece.swift
Created July 22, 2015 07:22
そういえば guard でも普通に where が使えるんですね。 #CodePiece
guard let string = string where !string.isEmpty else {
}
@braitom
braitom / .gitignore
Created January 26, 2015 05:36
gitignore for Carthage
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
@kirsteins
kirsteins / Array -> UnsafeMutablePointer -> Array
Last active June 16, 2024 09:42
Array -> UnsafeMutablePointer -> Array
var initalArray = [1, 2, 3]
let pointer: UnsafeMutablePointer<Int> = UnsafeMutablePointer(initalArray)
let arrary = Array(UnsafeBufferPointer(start: pointer, count: initalArray.count))
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [statuses count];
}
<font>
</font>
<font>