Skip to content

Instantly share code, notes, and snippets.

View yamaya's full-sized avatar

Masayuki Yamaya yamaya

  • Sapporo, Hokkaido, Japan
View GitHub Profile
@ashfurrow
ashfurrow / Fresh macOS Setup.md
Last active October 14, 2024 10:28
All the stuff I do on a fresh macOS Installation

Apps to install from macOS App Store:

  • Pastebot
  • GIF Brewery
  • Slack
  • Keynote/Pages/Numbers
  • 1Password
  • OmniFocus 3
  • Airmail 3
  • iA Writer
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleIdentifier</key>
<string>net.von-gagern.UsbWorkaround</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>

Swift Don'ts

  • Don't add code cruft. Avoid parentheses around conditions in if-statements or with the return keyword. Don't add semicolons except where syntactically demanded in statements or to separate statements on the same line.
  • Don't use ALL_CAPS; use camelCase
  • Don't fight type inference. Use enumeration prefixes, self-references, and class names (with constructors) only when necessary or to clarify coding intent.
  • Don't use var when let is appropriate, especially for properties. The compiler better optimizes let statements for items whose values will not change during their lifetime. For example, Apple writes, "It is good practice to create immutable collections in all cases where the collection does not need to change. Doing so enables the Swift compiler to optimize the performance of the collections you create."
  • Don't use classes when structs will do. Use class
@erica
erica / gist:3443158e6138a887deb3
Last active December 11, 2018 00:46
Tuplized if let
//
// TupleAssignment.swift
// Hello Swift
//
// Created by Erica Sadun on 12/19/14.
// Copyright (c) 2014 Erica Sadun. All rights reserved.
//
import Foundation
@neonichu
neonichu / source.lang.swift.md
Created February 13, 2015 21:44
Identifiers for Swift language entities
$ strings /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/sourcekitd.framework/Versions/Current/XPCServices/SourceKitService.xpc/Contents/MacOS/SourceKitService|grep source.lang.swift
source.lang.swift.keyword
source.lang.swift.pattern
source.lang.swift.syntaxtype.argument
source.lang.swift.syntaxtype.parameter
source.lang.swift.attribute.availability
source.lang.swift.decl.extension
source.lang.swift.decl.var.parameter
source.lang.swift.stmt.brace
@satoshin2071
satoshin2071 / gist:249d42fc563ce98b410b
Created November 27, 2014 08:20
#CoreFoundation入門 基本クラス その2

#CoreFoundation入門 基本クラス その2

概要

一回目の続き

CFData

bytebufferを扱う(ラッパー)クラス。NSDataとToll-free bridgingが可能

@haranicle
haranicle / UniversalFrameworkMaker.sh
Last active October 27, 2015 01:29
A shell script to create an universal cocoa framework.
#!/bin/sh
FrameworkName="MyKitName"
rm -rf ./Debug
mkdir ./Debug
cp -r ./Debug-iphoneos/${FrameworkName}.framework ./Debug/${FrameworkName}.framework
lipo -create ./Debug-iphoneos/${FrameworkName}.framework/${FrameworkName} ./Debug-iphonesimulator/${FrameworkName}.framework/${FrameworkName} -output ./Debug/${FrameworkName}.framework/${FrameworkName}
@comuttun
comuttun / KeySetting.diff
Created October 19, 2014 18:38
Change Space and Shift+Space behavior for JapaneseIM on OS X Yosemite
diff --git a/KeySetting_Ainu.plist b/KeySetting_Ainu.plist
index 197b151..809b6b8 100644
--- a/KeySetting_Ainu.plist
+++ b/KeySetting_Ainu.plist
@@ -13,14 +13,14 @@
<key>command</key>
<string>direct_input</string>
<key>character</key>
- <string> </string>
+ <string> </string>
@mattt
mattt / regex.swift
Created August 11, 2014 18:08
Creating a regular expression object from a String literal
class Regex {
let pattern: String
let options: NSRegularExpressionOptions!
private var matcher: NSRegularExpression {
return NSRegularExpression(pattern: self.pattern, options: nil, error: nil)
}
required init(pattern: String, options: NSRegularExpressionOptions = nil) {
self.pattern = pattern
var dict = Dictionary<String,Bool>()
dict["a"] = true
dict["c"] = false
func matchOneOrTheOtherWithOptionals(a: Bool?, b: Bool?) -> String {
switch (a, b) {
case (.Some(true), let b) where b == .None || !b!:
return "a was true, but b was None or false"
case (let a, .Some(true)) where a == .None || a == .Some(false):