Skip to content

Instantly share code, notes, and snippets.

View ktanaka117's full-sized avatar

Tanaka Kenji ktanaka117

View GitHub Profile
import Cocoa
import MASShortcut
func pow() {
let rect = NSScreen.mainScreen()?.frame
let window = NSWindow(contentRect: rect!, styleMask: NSBorderlessWindowMask, backing: .Buffered, `defer`: false)
window.backgroundColor = NSColor.clearColor()
window.opaque = false
window.alphaValue = 1
window.makeKeyAndOrderFront(NSApplication.sharedApplication())
@gwengrid
gwengrid / TypeErasure.swift
Last active September 12, 2018 05:14
Example of type erasure with Pokemon
class Thunder { }
class Fire { }
protocol Pokemon {
typealias PokemonType
func attack(move:PokemonType)
}
struct Pikachu: Pokemon {
typealias PokemonType = Thunder
@es-kumagai
es-kumagai / sample.swift
Last active October 14, 2015 08:43
暗黙アンラップな列挙型の値を switch にかけるとき。 Ref: https://twitter.com/ktanaka117/status/654199236070764544
enum ClientType {
case Main
case Sub
}
struct MyStruct {
var type:ClientType!
@sasaki-shigeo
sasaki-shigeo / gist:3727810
Created September 15, 2012 13:18
Conversion from/to Numeric Type in Scala (Scala における数値型の変換)
import math._
1L // Long型の 1
1:Long // Long型の 1
127:Byte // Byte型の 127
32767:Short // Short型の 32767
(1+2).toLong // Long型への変換
(2+3) toLong // Long型への変換