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
function peco_rspec | |
find . -follow -name "*_spec.rb" | peco | read -l file_name | |
echo "bin/rspec $file_name" | |
bin/rspec $file_name | |
commandline "bin/rspec $file_name" | |
end |
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
function peco_ssh | |
awk ' | |
tolower($1)=="host" { | |
for(i=2;i<=NF; i++) { | |
if ($i !~ "[*?]") { | |
print $i | |
} | |
} | |
} | |
' ~/.ssh/config | sort | peco | read -l hostname |
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 EnumHelpRansack | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def enums_i18n_ransack(enum_name) | |
enums = eval("self.#{enum_name.to_s.pluralize}") | |
enums.map { |k, v| [eval("self.#{enum_name.to_s.pluralize}_i18n")[k], v] } | |
end | |
end | |
end |
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
ko.bindingHandlers.cursor_wait = { | |
init: function(element, valueAccessor) { | |
ko.computed({ | |
read: function() { | |
if (ko.unwrap(valueAccessor())) | |
document.body.style.cursor = 'wait'; | |
else | |
document.body.style.cursor = 'auto'; | |
}, | |
disposeWhenNodeIsRemoved: element |
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
# Put this code in lib/validators/json_type_validator.rb | |
# Usage in your model: | |
# validates :json_attribute, json_type: true | |
# | |
# To have a detailed error use something like: | |
# validates :json_attribute, presence: true, json_type: {message: :some_i18n_key} | |
# In your yaml use: | |
# some_i18n_key: "detailed exception message: %{exception_message}" | |
# | |
# @see https://gist.github.com/joost/7ee5fbcc40e377369351 |
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
ko.bindingHandlers.nl2br = { | |
update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { | |
var field = ko.utils.unwrapObservable(valueAccessor()); | |
var lines = field.split(/\r\n|\r|\n/).map(function(line) { return document.createTextNode(line) }); | |
var div = document.createElement('div'); | |
lines.forEach(function(line, idx, lines) { | |
div.appendChild(line); | |
if (idx !== lines.length - 1) { | |
div.appendChild(document.createElement('br')) | |
} |
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
/** | |
* Bootstrap3でカラムを中央揃えにする | |
* | |
*/ | |
@for $i from 1 through ($grid-columns / 2) { | |
$columns: $i * 2; | |
$offset: ($grid-columns - $columns) / 2; | |
.col-xs-center-#{$columns} { | |
@include make-xs-column-offset($offset); | |
@include make-xs-column($columns); |
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
%text-align-justify { | |
text-align: justify; | |
text-justify: inter-ideograph; | |
} |
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
<!-- app/views/foos/_form.html.erb --> | |
<%= file_field_tag '', | |
style: 'display: none', | |
data: { | |
bind: "s3DirectUpload: { start: start_direct_upload, done: finished_direct_upload, fail: failed_direct_upload, progressall: progress_direct_upload }", | |
'form-data': @s3_direct_post.fields, | |
url: @s3_direct_post.url, | |
host: Url.parse(@s3_direct_post.url).host | |
} %> |
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
.col-xs-1-5, .col-sm-1-5, .col-md-1-5, .col-lg-1-5, | |
.col-xs-2-5, .col-sm-2-5, .col-md-2-5, .col-lg-2-5, | |
.col-xs-3-5, .col-sm-3-5, .col-md-3-5, .col-lg-3-5, | |
.col-xs-4-5, .col-sm-4-5, .col-md-4-5, .col-lg-4-5 { | |
position: relative; | |
min-height: 1px; | |
padding-left: ($grid-gutter-width / 2); | |
padding-right: ($grid-gutter-width / 2); | |
} | |
@for $i from 1 through 4 { |