This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn.
Please make sure that your Gemfile in your rails application includes unicorn.
class BootstrapFormBuilder < ActionView::Helpers::FormBuilder | |
def get_error_text(object, field, options) | |
if object.nil? || options[:hide_errors] | |
"" | |
else | |
errors = object.errors[field.to_sym] | |
if errors.empty? then "" else errors.first end | |
end | |
end |
$stack, $draws = [], {} | |
def method_missing *args | |
return if args[0][/^to_/] | |
$stack << args.map { |a| a or $stack.pop } | |
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
end | |
class Array | |
def +@ |
PostgreSQLでテーブルのデータファイル名を確認する方法。 | |
PostgreSQLでは、1テーブル/1インデックス毎に1ファイルが割り当てられる。 | |
ディスク容量にあまり余裕がない場合などに、大きなファイルを持つテーブルを、 | |
別ディスクに移動させたければ、 | |
ALTER TABLE 表名 SET TABLESPACE テーブルスペース名; | |
などとして別領域へ移動させたい場合がある。 | |
しかし、ファイル名には一意な数値が使用されているため、どのファイルがどのテーブルの | |
ものなのかパッと見では判別できない。 |
#!/usr/bin/env ruby | |
require 'mechanize' | |
require 'pry' | |
class Agent | |
def initialize(login, password) | |
@agent = Mechanize.new | |
@agent.pluggable_parser['appilcation/epub+zip'] = Mechanize::Download | |
@login, @password = login, password | |
end |
# ------------------------ | |
# add the following packages to rubber.yml: | |
# ------------------------ | |
packages: [postfix, libio-socket-ssl-perl, libxml-libxml-perl, unzip] | |
# ------------------------ | |
# add to config/rubber/custom-setup.rb: | |
# ------------------------ |
require './lib/backup/database/heroku_pgbackups.rb' | |
Backup::Model.new(:heroku, 'Heroku hosted data') do | |
database Backup::Database::HerokuPgbackups do |db| | |
db.name = 'my-heroku-app-name' | |
end | |
# Followed by other databases, storage, compression, etc. | |
end |
# This does not appear to recognize the :target => "_blank" when the page is rendered | |
simple_format(auto_link(@task.description, :html => { :target => "_blank" })) | |
# However, this works fine | |
auto_link(simple_format(@task.description), :html => { :target => "_blank" }) |
require 'aws/s3' | |
require 'heroku' | |
require 'heroku/command' | |
require 'heroku/command/auth' | |
require 'heroku/command/pgbackups' | |
task :cron do | |
class Heroku::Auth | |
def self.client | |
Heroku::Client.new ENV['heroku_login'], ENV['heroku_passwd'] |