This file contains hidden or 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
CREATE OR REPLACE FUNCTION resync_id_sequences() RETURNS void AS $$ | |
DECLARE | |
table RECORD; | |
sequence_name VARCHAR; | |
id_present RECORD; | |
max_id RECORD; | |
BEGIN | |
FOR table IN SELECT * FROM information_schema.tables WHERE table_schema = 'public' LOOP | |
SELECT COUNT(*) AS count INTO id_present | |
FROM pg_attribute a INNER JOIN pg_class c |
This file contains hidden or 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
find public/images -name '*.png' | xargs optipng | |
find public/images -name '*.jpg' | xargs jpegoptim |
This file contains hidden or 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
upstream unicorn-myapp { server 127.0.0.1:3000; } | |
server { | |
server_name myapp.com; | |
rewrite ^(.*) http://www.myapp.com$1 permanent; | |
} | |
server { | |
listen *:80; | |
server_name www.myapp.com; |
This file contains hidden or 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
/* Adapted from Tom Cunningham's 'Data Warehousing with MySql' (www.meansandends.com/mysql-data-warehouse) */ | |
###### small-numbers table | |
DROP TABLE IF EXISTS numbers_small; | |
CREATE TABLE numbers_small (number INT); | |
INSERT INTO numbers_small VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); | |
###### main numbers table | |
DROP TABLE IF EXISTS numbers; | |
CREATE TABLE numbers (number BIGINT); |
This file contains hidden or 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 'bundler/capistrano' | |
require 'rvm/capistrano' | |
set :application, 'myapp' | |
set :repository, '[email protected]:johngrimes/myapp.git' | |
set :scm, 'git' | |
set :bundle_flags, '--deployment' | |
set :bundle_without, [] |
This file contains hidden or 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 :seed_data do | |
desc 'Load seed data into the database of the current environment' | |
task :load => :environment do | |
require 'active_record/fixtures' | |
Dir.glob(RAILS_ROOT + '/db/seed_data/*.yml').each do |file| | |
Fixtures.create_fixtures('db/seed_data', File.basename(file, '.*')) | |
end | |
end | |
end |
This file contains hidden or 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
$timeStart = microtime(true); | |
/* The code that you want to time */ | |
$timeEnd = microtime(true); | |
$duration = $timeEnd - $timeStart; |
This file contains hidden or 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
var email = new LiveValidation('email'); | |
email.add(Validate.Presence); | |
email.add(Validate.Format, { pattern: /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/i }); |
NewerOlder