- ダッシュボード
- 何も考えずに各モデルをカウントするのでレコード件数増えるとえらいことになる。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
attr_reader :hoge, :fuga, | |
def initialize(a, b) | |
p a | |
p b | |
end | |
end | |
Foo.new # => no error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
id=$(pw-dump Node | jq -r 'map({id: .id, class: .info.props["media.class"], desc: .info.props["node.description"]} | select(.desc != null)) | sort_by(.class, .desc) | .[] | [.id, .class, .desc] | @tsv' | wofi -di | cut -f 1) | |
if [ -n "$id" ]; then | |
echo "Setting default to $id" | |
wpctl set-default $id | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM appbase | |
# install npm & bower packages | |
WORKDIR /root | |
COPY package.json bower.json /root/ | |
RUN npm install --only=prod && \ | |
npm cache clean && \ | |
bower install --allow-root | |
# install gems |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
instance_ids="" | |
device_name="" | |
for vol in $(aws ec2 describe-instances --region ap-northeast-1 --instance-ids ${instance_ids} | jq '.Reservations[].Instances[] | .BlockDeviceMappings[] | select(.DeviceName == "'${device_name}'") | .Ebs.VolumeId' -r); do | |
current=$(aws ec2 describe-volumes --volume-ids ${vol} | jq '.Volumes[] | .Size') | |
target=$(expr $current + 50) | |
echo "${vol}: ${current} -> ${target}" | |
echo "aws ec2 modify-volume --volume-id ${vol} --size ${target} --dry-run" | |
#aws ec2 modify-volume --volume-id ${vol} --size ${target} --dry-run | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in [1, 2, 3] | |
p i | |
j = i | |
end | |
p j | |
[1, 2, 3].each do |k| | |
l = k | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateUsers < ActiveRecord::Migration | |
def change | |
create_table :users do |t| | |
t.string :name | |
t.references :user_account | |
t.timestamps null: false | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :docker do | |
desc "build and push docker image on remote host" | |
task :build do | |
docker_registry_host = SSHKit::Host.new(fetch(:docker_registry_host)) | |
docker_registry_host.ssh_options = { | |
user: "ec2-user", | |
keys: ENV['SSH_KEY'], | |
} | |
sha1 = `git rev-parse #{fetch(:branch)}`.chomp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "debug_inspector" | |
class Foo | |
def meth1(&block) | |
RubyVM::DebugInspector.open do |dc| | |
iseq = dc.frame_iseq(2) | |
trace = TracePoint.new(:b_return) do |tp| | |
pp tp | |
tp.disable | |
end |
NewerOlder