Skip to content

Instantly share code, notes, and snippets.

View mknkisk's full-sized avatar
🐈‍⬛
🐈

Keisuke Makino mknkisk

🐈‍⬛
🐈
  • stores, Inc
  • Tokyo, Japan
View GitHub Profile
@mknkisk
mknkisk / web-api-the-good-parts-note.md
Last active March 31, 2020 09:34
Web API: The Good Parts / Note
@mknkisk
mknkisk / ssh-change-profile.sh
Created March 20, 2019 12:12
bin/ssh-change-profile.sh
#!/bin/bash
# set profile
echo -ne "\033]1337;SetProfile=Remote\a"
# ssh login
/usr/bin/ssh "$@"
# set profile(default)
echo -ne "\033]1337;SetProfile=Default\a"
@mknkisk
mknkisk / mongoid_not_allowed_fields_detector.rb
Last active February 25, 2019 02:52
mongoid v6.1.1 not allowed fields detector
#! /usr/bin/ruby
# frozen_string_literal: true
# USAGE:
# {RAILS_ROOT}/bin/rails r mongoid_not_allowed_fields_detector.rb
Rails.application.eager_load!
# mongoid v6.1.1
# Mongoid.destructive_fields
@mknkisk
mknkisk / app.js
Created February 11, 2017 15:45
Install client for airbrake (errbit) for express application
const airbrake = require('airbrake').createClient("your project ID", "your api key")
// errbit run on localhost
airbrake.protocol = 'http'
airbrake.serviceHost = 'localhost:3001'
// By default only the errors from the production environment will get reported
// If you put 'production' in airbrake.env, errors will reported
airbrake.env = 'production'
// routing
app.use('/', index)
git branch -r --merged master | grep -v -e master -e release -e staging/ | sed -e 's% *origin/%%' | xargs -I% git push --delete origin %
@mknkisk
mknkisk / gist:e27e89ddf89c95bff51befd7ee5f4509
Last active April 18, 2020 18:27
aws glacier -> aws s3
for key in `aws s3api list-objects --bucket {bucket_name} --output json | jq -r '.Contents[].Key'`; do echo $key; aws s3api restore-object --bucket {bucket_name} --key $key --restore-request '{"Days": 1}'; done
for key in `aws s3api list-objects --bucket {bucket_name} --output json | jq -r '.Contents[].Key'`; do echo "\n$key"; aws s3api head-object --bucket {bucket_name} --key $key --output json | jq -r .Restore; done
for key in `aws s3api list-objects --bucket {bucket_name} --prefix {path} --output json | jq -r '.Contents[].Key'`; do echo "\n$key"; aws s3 cp s3://{bucket_name}/$key ./; done
require 'spec_helper'
describe package('nginx') do
it { should be_installed }
end
describe service('nginx') do
it { should be_enabled }
it { should be_running }
end
@mknkisk
mknkisk / cookbooks_nginx_default.rb
Last active May 14, 2016 17:54
Itamae Nginx Recipe
# Nginx をインストール
package 'nginx'
# Nginx
service 'nginx' do
# サービスの有効化, 起動
action [:enable, :start]
end
#!/bin/bash
merge_commit=$(ruby -e 'print (File.readlines(ARGV[0]) & File.readlines(ARGV[1])).last' <(git rev-list --ancestry-path $1..master) <(git rev-list --first-parent $1..master))
if git show $merge_commit | grep -q 'pull request'
then
pull_request_number=$(git log -1 --format=%B $merge_commit | sed -e 's/^.*#\([0-9]*\).*$/\1/' | head -1)
url="`hub browse -u`/pull/${pull_request_number}"
echo $url
fi
open $url
@mknkisk
mknkisk / zundoko.rb
Created March 24, 2016 11:05
ZUN ZUN ZUN ZUN DOKO KIYOSHI
module ZunDoko
Z = 'ズン'
D = 'ドコ'
TARGET = [Z, Z, Z, Z, D]
def self.kiyoshi(arr=[])
arr.shift if arr.size > 4
arr << [Z, D].sample
return "#{arr.join("\s")} #{'キ・ヨ・シ!'}" if arr == TARGET