Skip to content

Instantly share code, notes, and snippets.

View linyows's full-sized avatar

Tomohisa Oda linyows

View GitHub Profile
module Mongoid
module MultiParameterAttributes
protected
# Override mongoid / lib / mongoid / multi_parameter_attributes.rb
def instantiate_object(field, values_with_empty_parameters)
return nil if values_with_empty_parameters.all? { |v| v.nil? } || !field
values = values_with_empty_parameters.collect { |v| v.nil? ? 1 : v }
klass = field.type
if klass == DateTime || klass == Date || klass == Time
module ActionView
module Helpers
class DateTimeSelector
# Override
# クレジットカード用に年を2桁で表示する "use_short_year" オプションを追加した
def select_year
if !@datetime || @datetime == 0
val = '1'
middle_year = Date.today.year
else

aaa

111

  • aaaaa
alert('aaa');
alert('hello');
#!/bin/sh
ID=$1
curl http://pastebin.com/Kc9ng18h | grep $ID
curl http://pastebin.com/vCMndK2L | grep $ID
curl http://pastebin.com/JdQkuYwG | grep $ID
curl http://pastebin.com/fw43srjY | grep $ID
curl http://pastebin.com/jv4LBjPX | grep $ID
@linyows
linyows / gist:2908423
Created June 11, 2012 03:48
javascript hash merge
var a = {aaa: 1, bbb: 2, ccc: 3};
var b = {ddd: 4, eee: 5};
var Hash = function(hash){
this.hash = hash;
};
Hash.prototype.merge = function(target) {
for (var i in target) {
if (typeof target[i] === 'function') { continue; }
if (typeof target[i] === 'object') { continue; }
@linyows
linyows / colorize.pl
Created June 16, 2012 05:22 — forked from Cside/colorize.pl
colorize keywords of logs.
#!/usr/bin/env perl
=head1 Examples
$ tail -f access_log | perl colorize.pl
$ plackup app.psgi 2>&1 | perl colorize.pl
=cut
use strict;
@linyows
linyows / gist:3422581
Created August 22, 2012 05:41
ride on unicorn
#!/bin/sh
#
# color
#
RES_COL=60
MOVE_TO_COL="echo -en \\033[${RES_COL}G"
SETCOLOR_SUCCESS="echo -en \\033[1;32m"
SETCOLOR_FAILURE="echo -en \\033[1;31m"
SETCOLOR_WARNING="echo -en \\033[1;33m"
var startDate = new Date(2012, 8-1, 31);
var endDate = new Date(2012, 8-1, 31);
if (startDate.getTime() <= nowDate.getTime() && nowDate.getTime() < endDate.getTime()) {
}
#!/usr/bin/env ruby
remote = `git remote -v | grep origin | awk '{print $2}'`.
split("\n").first.chomp.
sub(/.*:(.*)/, '\1').sub(/\.git/, '')
log = `git log --after=yesterday --author='linyows'`
#log = `git log --author='linyows'`
commits = {}
count = 0
# 2. Include Sweeping module in your controller(s) to have cache_sweeper
# method to be avaliable, or right in ApplicationController so it will be
# available in all controllers inheriting from it.
class ApplicationController < ActionController::Base
include ActionController::Caching::Sweeping
# ...
end