This file contains 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
#! /usr/bin/env ruby | |
exec("LANG=ja_JP.sjis grep -rn `echo #{ARGV[0]} | nkf -s` #{ARGV[1]} | nkf -w") |
This file contains 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
# frozen_string_literal: true | |
module Refinements | |
module AssociationCollectionExtension | |
refine ActiveRecord::Associations::CollectionProxy do | |
def find_or_build_by(arguments) | |
find_by(arguments) || build(arguments) | |
end | |
def detect_or_build_by(arguments) | |
self.detect do|instance| |
This file contains 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
$ -> | |
jQuery.extend jQuery.fn, | |
toggle_value: -> | |
obj = jQuery(this) | |
obj.val ((if obj.val() is "true" then "false" else "true")) | |
exists: -> | |
@length > 0 | |
enable: -> | |
$(this).removeAttr "disabled" | |
disabled: -> |
This file contains 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 ExtendBuiltInDataType | |
class ::Hash | |
def merge_apend_value(hash) #{{{ | |
self.update(hash) do |key, self_val, other_val| | |
Array.wrap(self_val).push(other_val) | |
end | |
end #}}} | |
end | |
end |
This file contains 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
/* hoverの系の順序 */ | |
a:link { color: #999ea1 } | |
a:visited { color: #999ea1 } | |
a:hover { color: #999ea1 } | |
a:active { color: #999ea0 } |
This file contains 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
// String {{{ | |
String.prototype.trim = function() { | |
return this.replace(/^\s+|\s+$/g, ""); | |
} | |
String.prototype.ltrim = function() { | |
return this.replace(/^\s+/, ""); | |
} | |
String.prototype.rtrim = function() { | |
return this.replace(/\s+$/, ""); | |
} |
This file contains 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
# coding: utf-8 | |
require 'date' | |
# | |
# カレンダークラス | |
# | |
# 実装(予定)機能 | |
# (1)コンソールへの出力 ->○ | |
# (2)テーブル形式での出力 ->○ | |
# (3)休日を考慮 |
This file contains 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
class MultiSelectWithoutCtrl | |
constructor: (_this, options)-> | |
@id = null | |
@name = options["name"] | |
@select = _this | |
@checkboxes = $("<div class='hidden_multi_select'></div>") | |
@select.after(@checkboxes) | |
@selected() | |
selected: -> | |
@select.on "click" , (event) => |
This file contains 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
# lib/active_record/real_delete_discreetly.rb | |
module RealDeleteDiscreetly | |
extend ActiveSupport::Concern | |
def delete_discreetly | |
relation_exist = false | |
self.class.confirm_relations.each do |confirm_relation| | |
if destroyed_by_association | |
if destroyed_by_association.active_record == confirm_relation.to_s.classify.constantize | |
relation_exist = false |
This file contains 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
# http://stackoverflow.com/questions/6317705/rackrequest-how-do-i-get-all-headers | |
require 'rack' | |
app = Proc.new do |env| | |
headers = env.select {|k,v| k.start_with? 'HTTP_'} | |
.collect {|pair| [pair[0].sub(/^HTTP_/, ''), pair[1]]} | |
.collect {|pair| pair.join(": ") << "<br>"} | |
.sort | |
[200, {'Content-Type' => 'text/html'}, headers] | |
end |
NewerOlder