This file contains hidden or 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
def to_camelize(str) | |
s = str.split(/_/).map{|s| s.capitalize}.join('') | |
s[0] = s[0].downcase | |
s | |
end | |
underscore = 'apple_orange_banana' | |
camelize = to_camelize(underscore) | |
p camelize |
This file contains hidden or 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
type_map = { | |
'integer' => 'Int', | |
'string' => 'String', | |
} | |
type_string = 'integer' | |
type_swift = type_map[type_string] | |
p type_swift |
This file contains hidden or 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 | |
extension SequenceType where Generator.Element : Equatable { | |
typealias E = Generator.Element | |
// use reduce() | |
func group() -> [[E]] { | |
let initial: [[E]] = [] | |
let grouped = self.reduce(initial) { (var acc, x) -> [[E]] in |
This file contains hidden or 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
def swift_files(path, files) | |
Dir::glob(path + '/*').each {|fname| | |
if fname.include?('Test') # no search test dir & files | |
return | |
end | |
if FileTest.directory?(fname) | |
swift_files(fname, files) | |
else | |
if fname.include?('.swift') | |
files.push(fname) |
This file contains hidden or 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
// ==UserScript== | |
// @name GitHub Helper | |
// @namespace Yusuke.Hosonuma | |
// @description GitHubのコメントを全て開くボタンを追加 | |
// @match https://github.com/* | |
// ==/UserScript== | |
(function(){ | |
var target = document.getElementsByClassName('gh-header-actions'); | |
var button = document.createElement('button'); | |
button.innerHTML = 'Expand'; |
This file contains hidden or 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
<html> | |
<head> | |
<!-- <link rel="stylesheet" type="text/css" href="sample.css"> --> | |
<script src="script.js"></script> | |
</head> | |
<body> | |
<select id="week"> | |
<option>week1</option> | |
<option>week2</option> | |
<option>week3</option> |
This file contains hidden or 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
// | |
// MySubject.swift | |
// RxSwiftSample | |
// | |
// Created by Yusuke on 4/10/16. | |
// Copyright © 2016 Yusuke. All rights reserved. | |
// | |
import Foundation |
This file contains hidden or 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 UIKit | |
import RxSwift | |
import RxCocoa | |
class ViewController: UIViewController { | |
@IBOutlet weak var textView: UITextView! | |
@IBOutlet weak var countLabel: UILabel! | |
let disposeBag = DisposeBag() |
This file contains hidden or 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 UIKit | |
import RxSwift | |
import RxCocoa | |
let requiredUserNameLength = 5 | |
let requiredPasswordLength = 5 | |
let limitUserNameLength = 20 | |
class ValidationViewController: UIViewController { |
This file contains hidden or 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
module RLE where | |
import Data.List ( group, groupBy ) | |
-- | ランレングス圧縮 | |
-- | |
-- >>> rle "AAABBCCCCD" | |
-- "A3B2C4D1" | |
-- | |
-- >>> rle "AAAAAAAAAAB" |