Skip to content

Instantly share code, notes, and snippets.

View diskshima's full-sized avatar

Daisuke Shimamoto diskshima

View GitHub Profile
# A Ruby implementation to confirm when assignments happen.
# Inspired by https://ericlippert.com/2019/01/18/indexer-error-cases/
# Prints
# A
# B
# C
# catch
def a
@diskshima
diskshima / Gemfile
Last active April 19, 2018 04:47
Mackerel CLI
source 'https://rubygems.org'
gem 'mackerel-client'

Keybase proof

I hereby claim:

  • I am diskshima on github.
  • I am diskshima (https://keybase.io/diskshima) on keybase.
  • I have a public key ASBYl3gH3ynqwnM2aGYVpo0BcHhv6A7JTpVtYJj3zgMUNgo

To claim this, I am signing this object:

#! /usr/bin/env ruby
str = 'I, [2014-09-04T05:17:29.385333 #19220] INFO -- : Parameters: {"users"=>{"profile_url"=>"https://example.com/users/123", "status"=>"1"}}'
matches = /[DIWE], \[([0-9\-T:\.]+).* Parameters: ({.*)/.match(str)
matches.to_a.each_with_index do |m, index|
puts "#{index}: #{m}"
end
@diskshima
diskshima / oauth2_tester.rb
Last active November 27, 2015 09:36
Command Line OAuth2 Tester
#!/usr/bin/env ruby
#
# oauth2_tester.rb
# Copyright (C) 2015 Daisuke Shimamoto <shimamoto@lifeistech.co.jp>
#
# Distributed under terms of the MIT license.
#
# Usage: ruby oauth2_tester.rb AUTHORIZATION_URL APP_ID APP_SECRET SCOPE
@diskshima
diskshima / gow.rb
Last active October 29, 2015 11:51
Script to open Git Repository's Remote URL
#! /usr/bin/env ruby
# Please run the below command first.
# gem install git uri-ssh_git launchy
require 'git'
require 'uri/ssh_git'
require 'launchy'
dir = '.'
@diskshima
diskshima / rename_scss.sh
Created September 2, 2015 06:37
Shell script to rename .css.scss to .scss
#! /usr/bin/env bash
for f in $(find . -type f -iname '*.css.scss'); do
renamed=$(echo "${f}" | sed 's/.css.scss$/.scss/g')
cmd="git mv ${f} ${renamed}"
echo $cmd
eval $cmd
done
@diskshima
diskshima / file0.erb
Last active August 29, 2015 14:10
Rails Best Practices の警告をちゃんと考える ref: http://qiita.com/diskshima/items/a19273f14705bbdb3e14
<% unless @member.name.present? %>
名無しの権兵衛
<% end %>
@diskshima
diskshima / file0.rb
Created November 22, 2014 07:46
なぜか boolean の validates ~ presence がいつもエラーになる ref: http://qiita.com/diskshima/items/9c0b6286d68c0c13bb68
class Person < ActiveRecord::Base
validates :name, presence: true
end
@diskshima
diskshima / file0.css
Last active August 29, 2015 14:09
Metro アプリでフォントが使えない場合の対処法 ref: http://qiita.com/diskshima/items/602bdaf9800d6d36d7ab
@font-face {
font-family: "88ttf";
src: url("/fonts/88ttf.ttf") format('truetype');
}