Skip to content

Instantly share code, notes, and snippets.

View ezura's full-sized avatar

Yuka Ezura ezura

View GitHub Profile
<?php
/*
* If You want to prohibit that guest users display it,
* write in this group.
*/
Route::group(array('before' => 'auth'), function()
{
Route::get('/', array(
'uses' => 'MainController@index',
require "em-websocket"
require 'json'
require 'sinatra/base'
require 'thin'
$stdout.sync = true
# FIX_ME: port とか host とか直打ちしない
EventMachine.run {
@globalChannel = EM::Channel.new
@ezura
ezura / CustomClass.h
Last active August 29, 2015 14:26
クラスに [], {} を実装する ref: http://qiita.com/ezura/items/dd4ff9b0ae2a1afa3bb3
// id obj = custom[@1];
- (id)objectForKeyedSubscript:(id)key;
// custom[@1] = @0;
- (void)setObject:(id)anObject forKeyedSubscript:(id <NSCopying>)aKey;
@ezura
ezura / file0.txt
Last active November 26, 2015 03:39
playground でファイル読み込みをする (画像・テキストファイルなど) ref: http://qiita.com/ezura/items/be522ff45856392eedcf
playground -> "パッケージの内容を表示" -> Resources ディレクトリ作成
@ezura
ezura / file0.swift
Last active November 26, 2015 12:34
playground で非同期通信をする ref: http://qiita.com/ezura/items/b17fec1240654028d265
import XCPlayground
@ezura
ezura / gist:68e3370a6df1502ba2db
Last active December 5, 2015 14:50
jiyugaoka:Swift? #0 でいろいろ試してみたコードたち
/*
* 下記サイトの問題を題材にさせていただきました
* is AnyObject?: http://qiita.com/taketo1024/items/21d8c5fb81ab388ccdb6
*/
import Foundation
() is AnyObject
1 is AnyObject
(1, 2) is AnyObject
@ezura
ezura / SequenceType.swift
Created December 17, 2015 13:14
要素に必ずしも実体が必要ないことの説明 (アクセスしたとき値ができる)
struct SampleStruct {}
extension SampleStruct : SequenceType {
typealias Generator = SampleGenerator
func generate() -> Generator {
return Generator()
}
}
struct SampleGenerator : GeneratorType {
// 詳しい解説は下記
// https://trifort.jp/blog/development/%E6%8E%A2%E6%A4%9C%EF%BC%81swiftyjson-%E5%89%8D%E7%B7%A8/
struct SampleStruct {
var object:Any?
}
// ここに実装を追加していきます
// [] を実装
extension SampleStruct {
@ezura
ezura / Printable,DebugPrintable実装時
Last active December 20, 2015 12:00
自作クラス、構造体の \(), print() をカスタマイズする ref: http://qiita.com/ezura/items/8f31b14bd1418a0dab81
class DescriptionSample: Printable, DebugPrintable {
var m = "sample"
// Printable
var description: String {
return "\(m) description"
}
// DebugPrintable
var debugDescription: String {
return "\(m) debugDescription"
}
@ezura
ezura / CodePiece.swift
Created February 6, 2016 06:41
エラー、出てくれるのね(。 ・ω・)) #CodePiece #cswift
protocol A {
func protocolAFunc ();
}
protocol B {
func protocolBFunc ();
}
struct Sample {
func protocolAFunc() {