Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
remote="origin"
if git remote | grep fork >/dev/null 2>&1; then
remote="fork"
fi
branch="$(git rev-parse --abbrev-ref HEAD)"
git push -u $remote $branch
@a2ikm
a2ikm / fiber_yield.rb
Created April 18, 2018 06:54
Fiberの1回目のresumeでとりあえずブロック処理に突入させる
fib = Fiber.new do
Fiber.yield # y1
a, b = 1, 1
while true
Fiber.yield(a) # y2
a, b = b, a + b
end
end
fib.resume # y1まで進める
@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