FridayHug.com http://fridayhug.com
The Smallest Rails App http://thesmallestrailsapp.com
%w(action_controller/railtie coderay).each &method(:require)
require 'jeff' | |
module MWS | |
class Request | |
include Jeff | |
HOSTS = { | |
'A2EUQ1WTGCTBG2' => 'mws.amazonservices.ca', | |
'AAHKV2X7AFYLW' => 'mws.amazonservices.com.cn', | |
'A1PA6795UKMFR9' => 'mws-eu.amazonservices.com', |
require 'benchmark' | |
require './lib/excon' | |
include Excon | |
uris = { | |
'Good URI' => "http://example.org/#{'foo/' * 10}?#{10.times.map { 'bar=baz' }.join('&')}", | |
'Bad URI' => "http://example.org/#{'foo /' * 10}?#{10.times.map { 'bar=baz' }.join('&')}" | |
} |
FridayHug.com http://fridayhug.com
The Smallest Rails App http://thesmallestrailsapp.com
%w(action_controller/railtie coderay).each &method(:require)
#!/usr/bin/env bash | |
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz | |
mkdir vim && tar xzvf vim.tar.gz -C vim | |
export PATH=$PATH:/app/vim/bin |
#!/usr/bin/ruby -w | |
require 'digest/md5' | |
filename = 'MD5.rdoc' | |
all_digest = Digest::MD5.hexdigest(File.read(filename)) | |
incr_digest = Digest::MD5.new() | |
file = File.open(filename, 'r') | |
file.each_line do |line| | |
incr_digest << line |
# config/initializers/sidekiq.rb | |
if Sidekiq.server? | |
config = ActiveRecord::Base.connection.pool.spec.config | |
ActiveRecord::Base.establish_connection(config.merge(pool: Sidekiq.options.fetch(:concurrency))) | |
end |
/* How to calculate postgreSQL database size in disk ? */ | |
SELECT pg_size_pretty(pg_database_size('thedbname')); | |
/* Calculate size of a table including or excluding the index */ | |
SELECT pg_size_pretty(pg_total_relation_size('big_table')); | |
SELECT pg_size_pretty(pg_relation_size('big_table')); /* without index */ | |
/* See indexes on a table with `\d tablename` */ |
/etc/ssh/sshd_config
, add your public key to root's authorised keys, and so on.mv /home /home.bak
.home
in /etc/fstab
.home.bak
back to home
.mv /var/lib/postgresql /var/lib/postgresql.bak
./etc/fstab
, remove comment and replace /home
with /var/lib/postgresql
./var/lib/postgresql
with chown
it to postgres:postgres
.Sequel.migration do | |
up do | |
run 'CREATE EXTENSION "uuid-ossp"' | |
create_table :products do | |
column :id, :uuid, :default => Sequel.function(:uuid_generate_v4), :primary_key => true | |
end | |
end | |
end |
#!/bin/sh | |
filename=$1 | |
echo "Begin processing file:" $filename | |
dimensions=$(identify -format '%w %h' $filename) | |
IFS=' ' read -a array <<< "$dimensions" | |
width=${array[0]} | |
height=${array[1]} |