Skip to content

Instantly share code, notes, and snippets.

View chiastolite's full-sized avatar

Hiroyuki Morita chiastolite

View GitHub Profile
@chiastolite
chiastolite / hide-eplus-failure.js
Created March 21, 2021 11:03
eplusの非当選隠し
// ==UserScript==
// @name eplusの非当選隠し
// @version 0.1
// @author @chiastolite
// @match https://north2.eplus.jp/sys/main.jsp*
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.querySelectorAll("#contents > div.appli-situation > table > tbody:nth-child(2) > tr[class='win-failure']").forEach( function(element) { element.style.display ="none"; });
class Coupon < ApplicationRecord
scope :expired, -> { where('valid_until < ', Time.zone.now) }
def expired?
valid_until < Time.zone.now
end
end
#!/bin/bash
if [ $# -ne 1 ]; then
echo 'Usage: git new repository_name'
exit 1
fi
REPO_NAME=$1
REPO_DIR=$(ghq root)/github.com/$(whoami)/$REPO_NAME
# ログからクエリ発行が多いとこを特定するために呼出元を回数順に並べるやつ
# 途中のsedは色付け用のエスケープシーケンスを消すやつ
grep 'ActiveRecord::Cause' log/development.log| sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g' | sort |uniq -c | sort -n
#!/bin/bash
# Gitリポジトリ内ではなければ処理をしない
git status > /dev/null 2>&1
if [ $? != 0 ] ; then
echo "Not a git repository"
exit 1
fi
# stagingされているファイルがある場合は処理をしない
if [ -n "`git diff --name-only --cached`" ]; then
@chiastolite
chiastolite / grouping.rb
Last active August 18, 2020 16:25
こんなのどうやるんだけ
FooModel.pluck(:hoge_id, :id)
# => [[1, 1], [1, 2], [2, 3], [3, 4], [3, 5]]
# ↑これを↓こんな風にhoge_id毎にまとめたい
# => {1 => [1, 2], 2 => [3], 3 => [4, 5]}
@chiastolite
chiastolite / gist:4b95d88811b6355ae540
Last active August 29, 2015 14:24
こういうhas_oneの使い方ってありなんだろうか?
class Entry < ActiveRecord:Base
has_many :messages
has_one :latest_message, -> { merge(Message.latest) }, class_name: 'Message'
end
class Message < ActiveRecord:Base
scope :latest, -> { order(id: :desc) }
end
                                       
                                       
                                       
             
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |spec|
spec.name = "ruboty-fluent-logger"
spec.version = "1.0.0"
spec.authors = ["chiastolite"]
spec.email = ["[email protected]"]
spec.summary = "foward all messages to fluentd"
spec.license = "MIT"
require 'bundler/setup'
Bundler.require
require 'google/api_client'
require 'google/api_client/client_secrets'
require 'google/api_client/auth/installed_app'
client = Google::APIClient.new(
:application_name => 'Example Ruby application',
:application_version => '1.0.0'
)