Skip to content

Instantly share code, notes, and snippets.

@manemone
manemone / _first_page.html.haml
Last active February 26, 2017 06:32
kaminari のページネーションリンクに Twitter Bootstrap 4 のスタイルを適用する ref: http://qiita.com/manemone@github/items/564c58ea59fb3450826c
%li.page-item.prev{ class: "#{'disabled' if current_page.first?}" }
= link_to (current_page.first? ? "#" : url), class: "page-link", "aria-label" => "First", :remote => remote do
%span{"aria-hidden" => "true"} «
%span.sr-only
= t('views.pagination.first').html_safe
@manemone
manemone / file0.swift
Last active April 17, 2018 16:29
Swift 4 でキャメルケースとスネークケースを変換する String 拡張 ref: https://qiita.com/manemone@github/items/f7ba2496d469992724df
// Swift 4 版 (String の extension として実装)
extension String {
// set `lower = false` in case you want "UpperCamel" output.
func camelized(lower: Bool = true) -> String {
guard self != "" else { return self }
let words = lowercased().split(separator: "_").map({ String($0) })
let firstWord: String = words.first ?? ""
let camel: String = lower ? firstWord : String(firstWord.prefix(1).capitalized) + String(firstWord.suffix(from: index(after: startIndex)))