Skip to content

Instantly share code, notes, and snippets.

@a2ikm
a2ikm / patch_migrate.ruby
Last active April 23, 2019 02:49
rake db:migrateでdevelopmentだけでなくtestもまとめてマイグレーション走らせるやつ for Rails 5.1
module ActiveRecord::Tasks::DatabaseTasks
class <<self
prepend Module.new {
def migrate(environment = env)
each_current_configuration(environment) { |configuration|
begin
ActiveRecord::Base.establish_connection(configuration)
super()
ensure
ActiveRecord::Base.establish_connection(environment.to_sym)
@a2ikm
a2ikm / tee_capistrano_log.rb
Last active February 15, 2018 03:04
Tee Capistrano3's logs to stdout and a log file.
before :deploy, :setup_tee do
require "tee" # tee gem
# root is where Capfile is placed.
root = File.dirname(File.expand_path(Rake.application.rakefile))
path = File.join(root, "log/deploy_#{release_timestamp}_#{local_user}.log")
FileUtils.mkdir_p(File.dirname(path))
file = File.open(path, "w").tap { |f| f.sync = true }
formatter = SSHKit.config.output

Keybase proof

I hereby claim:

  • I am a2ikm on github.
  • I am ikm (https://keybase.io/ikm) on keybase.
  • I have a public key ASC-htoOrKqZHAobMtu_RW0WbO4LrECHegJ6ZApDr6-uuwo

To claim this, I am signing this object:

@a2ikm
a2ikm / USAGE
Last active December 21, 2017 05:33
Log deprecated methods in Rails app
__deprecate def old_method(a, b, &bkock)
:
end
attr_accessor :old_accessor
__deprecate_accessor :old_accessor
attr_reader :old_reader
__deprecate_reader :old_reader
import Foundation
let GlobalQueue = DispatchQueue(label: "st.aerial.Yukon.queue")
class EchoServer {
// let localQueue = dispatch_queue_create("\(EchoServer.self)",
// DISPATCH_QUEUE_CONCURRENT)
var serverSocket: Int32
var clientsAccepted: [Int32 : DispatchSourceRead]
@a2ikm
a2ikm / git-ikm
Last active November 29, 2018 07:04 — forked from kosugi/git-ikm
#! /bin/bash
echo '吉高由里ふぃ子'
@a2ikm
a2ikm / filer_mpstat_usr
Created September 29, 2017 09:16
mpstat -P ALLから%usrだけを抜き出すやつ
#!/usr/bin/env ruby
@current = []
@header = false
def init(time, all)
@current << time
@current << all
end
[root@localhost ~]# nmcli con
[root@localhost ~]# nmcli con show System\ eth0
[root@localhost ~]# nmcli con mod System\ eth0 +ipv4.dns "8.8.8.8 8.8.4.4"
[root@localhost ~]# nmcli con mod System\ eth0 ipv4.ignore-auto-dns yes
[root@localhost ~]# systemctl restart NetworkManager
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 8.8.4.4
@a2ikm
a2ikm / gist:a2d0f6d049ad3999b53497a611ead552
Created September 1, 2017 05:49
strip all text attributes out of copy/pasting from Terminal
defaults write com.apple.Terminal CopyAttributesProfile com.apple.Terminal.no-attributes
@a2ikm
a2ikm / gist:5cf9d03637e1cab5ac2e7446e9f67115
Created September 1, 2017 05:48
strip all text attributes out of copy/pasting from Terminal
defaults write com.apple.Terminal CopyAttributesProfile com.apple.Terminal.no-attributes