Skip to content

Instantly share code, notes, and snippets.

Avatar
👶
parenting

Shinichi Maeshima willnet

👶
parenting
View GitHub Profile
@willnet
willnet / Gemfile
Created Feb 14, 2014
revenger.in の Gemfile
View Gemfile
# -*- coding: utf-8 -*-
source 'http://rubygems.org'
gem 'rails', '3.2.15'
gem 'mysql2'
gem 'unicorn'
gem 'rabl'
gem 'i18n-js'
gem 'roadie'
gem 'kaminari'
View gem-info
#!/bin/sh
echo "gem search -d ^${1}$"
gem search -d ^${1}$
View gem-info-all
#!/bin/sh
echo "gem search -da ^${1}$"
gem search -da ^${1}$
View test.rb
# -*- coding: utf-8 -*-
require 'voice_text_api'
require 'tempfile'
# https://github.com/tdtds/voice_text_api
vt = VoiceTextAPI.new('YOUR_API_KEY')
# wav = vt.tts('隣の客はよく柿食う客だ', :haruka, emotion: :happiness)
wav = vt.tts('隣の客はよく柿食う客だ', :haruka, emotion: :anger, emotion_level: 2)
View gist:4ce9332f90857189bc91
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
compression = 9
View circle.yml
test:
pre:
- "export PULL_REQUEST_ID=`bundle exec prid willnet/savanna` && if [ $PULL_REQUEST_ID ]; then cd .. && git clone git@github.com:willnet/savanna.git for_pronto && cd for_pronto && git checkout -b ${CIRCLE_BRANCH} remotes/origin/${CIRCLE_BRANCH} && bundle install && PULL_REQUEST_ID=`bundle exec prid willnet/savanna` bundle exec pronto run -c master -f github_pr && cd ../savanna; else echo 'current branch is not pull request'; fi"
@willnet
willnet / create_image.rb
Created Mar 27, 2015
create image whose file size you can specify for test
View create_image.rb
#
# brew install imagemagick exiftool
#
system('convert -size 128x128 xc:blue test.jpg')
file_size = 1_048_576 - 448
ascii = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
File.open('random.txt', 'w') do |file|
file.write(file_size.times.map { ascii.sample }.join)
View manage_old_logs.rb
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# ログローテーションでできた古いログファイルを整理するためのスクリプト
# script/runner で実行する
Dir.chdir(RAILS_ROOT + "/log")
today = DateTime.now.strftime("%Y%m%d")
thismonth = DateTime.now.strftime("%Y%m")
Dir.glob("*").each do |filename|
View remove_old_sessions.rb
#!/usr/bin/env ruby
# ActiveRecordで管理している古いsessionを削除するスクリプト
# デフォルトで14日以上前のレコードを削除
ENV["RAILS_ENV"] ||= "production"
require File.dirname(__FILE__) + '/../config/boot'
require File.dirname(__FILE__) + '/../config/environment'
num = ARGV.shift || 14
num = num.to_i
# puts RAILS_ENV
View log_rotate.rb
#
# log rotatation
#
# script/runner & cron で実行する
SERVER_PID = configatron.server.pid
ACCESS_LOG = configatron.server.access_log
ACCESS_LOG_STRFTIME = configatron.server.access_log_strftime
RAILS_LOG = configatron.server.rails_log
RAILS_LOG_STRFTIME = configatron.server.rails_log_strftime