Skip to content

Instantly share code, notes, and snippets.

View joker1007's full-sized avatar

Tomohiro Hashidate joker1007

View GitHub Profile
@joker1007
joker1007 / ginzarb_21.md
Last active April 14, 2021 06:41
Ginza.rb 21回の発表資料。rails_adminのつらみとオススメgem達。

rails_adminのつらみとオススメGemについて

rails_adminのつらみ

カスタマイズできるようで出来ない

レコード件数が一定以上になると使えない機能

  • ダッシュボード
  • 何も考えずに各モデルをカウントするのでレコード件数増えるとえらいことになる。
@joker1007
joker1007 / calculator.rb
Created January 17, 2015 06:25
神奈川Ruby会議01
require 'bundler/setup'
require 'tapp'
class Operator
def initialize(left, right)
@left = left
@right = right
end
end
@joker1007
joker1007 / mount_nas.scpt
Created November 16, 2014 11:12
特定のIPが割り当てられた時、NASを自動でマウントするAppleScript
global prevIpValue
set prevIpValue to ""
on idle
set newIpValue to IPv4 address of (get system info) as string
if newIpValue = "192.168.1.80" and not newIpValue = prevIpValue then
try
display alert "NASをマウントします"
@joker1007
joker1007 / cache_by_request.rb
Last active August 29, 2015 14:09
Rackミドルウェアとして動作する1リクエスト毎に勝手に消える超簡易キャッシュストア
class CacheByRequest
def self.read(key)
if Thread.current[:cache_by_request]
Thread.current[:cache_by_request].read(key)
else
raise "before CacheByRequest::Store initialization"
end
end
def self.write(key, val)
# @param [Hash] options Any of :log, :env, :pwd, :command, :stdout_log, :stderr_log, :spawn_options, :spawn_checker, :timeout
def spawn_process(options = {})
env = options[:env] || {}
command = options[:command]
stdout_log = options[:stdout_log] ? [options[:stdout_log], 'w'] : :out
stderr_log = options[:stderr_log] ? [options[:stderr_log], 'w'] : :err
pwd = options[:pwd]
spawn_options = {
:out => stdout_log,
:err => stderr_log,
#!/usr/bin/env ruby
require 'pp'
require 'rspec-power_assert'
class Point
attr_reader :row, :col
def initialize(row, col)
@row, @col = row, col
#!/usr/bin/env ruby
require 'pp'
BASE_TABLE = [
%w(a b c d e),
%w(f g h i j),
%w(k l m n o),
%w(p q r s t),
%w(u v w x y),
gulp = require('gulp')
plumber = require('gulp-plumber')
util = require('gulp-util')
sass = require('gulp-ruby-sass')
rimraf = require('gulp-rimraf')
uglify = require('gulp-uglify')
minifyCSS = require('gulp-minify-css')
streamify = require('gulp-streamify')
size = require('gulp-size')
tap = require('gulp-tap')
class Guardable
def initialize(obj)
@obj = obj
end
def method_missing(method_name, *args, &block)
return @obj if @obj.nil?
@obj.send(method_name, *args, &block)
end
#!/bin/sh
# 自分のコミットが少ない順にファイルを並べる
# Display all files sorted in the order your commit less
# output
# total[TAB]add[TAB]del[TAB]filename
while getopts "a:n:" OPT; do
case $OPT in