Skip to content

Instantly share code, notes, and snippets.

View lucascaton's full-sized avatar

Lucas Caton lucascaton

View GitHub Profile
$ rake db:migrate
(in /Users/lucascaton/projects/code/ruby/pessoais/golks)
== AddNameToMovies: migrating ================================================
-- add_column(:movies, :name, :string, {:null=>false})
rake aborted!
An error has occurred, this and all later migrations canceled:
PGError: ERROR: column "name" contains null values
: ALTER TABLE "movies" ALTER "name" SET NOT NULL
.block
.content
%h2.title="##{@person.id} #{@person.name}"
.inner
%h3 Filmes
%table.table
%tr
%th.first Image
%th=t 'activerecord.attributes.movie.name'
delete from movie_casts where id in (
select id from movie_casts where movie_id=5, person_id=63, job='Director' limit 1
);
delete from movie_casts where id in (
select id from movie_casts where movie_id=5 and person_id=67 and job='Original Music Composer' limit 1
);
delete from movie_casts where id in (
select id from movie_casts where movie_id=5 and person_id=69 and job='Editor' limit 1
delete from movie_casts where id in (
select id from movie_casts where movie_id=5 and person_id=64 and job='Producer' limit 1
);
delete from movie_casts where id in (
select id from movie_casts where movie_id=256 and person_id=2953 and job='Makeup Artist' limit 1
);
delete from movie_casts where id in (
select id from movie_casts where movie_id=443 and person_id=1568 and job='Producer' limit 1
array = []
start_time = Time.now
10000000.times do
array << rand(999999)
end
end_time = Time.now
puts "10 milhões de números randomicos em #{end_time - start_time} segundos..."
(3) - Chris Lighty
10060|41042
(4) - Heather Parry
10060
(5) - Sharon Seto
10060
(6) - Stuart Parr
10060
(7) - Paul Rosenberg
10060
sudo mvim /etc/apache2/httpd.conf
Find the line:
"#LoadModule php5_module libexec/apache2/libphp5.so"
And uncomment it (remove the #).
After, restart the Apache:
sudo apachectl restart
<?php
// Script written by Vladislav "FractalizeR" Rastrusny
// http://www.fractalizer.ru
//MySQL connection settings
$db_server = 'localhost';
$db_user="root";
$db_password="";
mysql_connect($db_server, $db_user, $db_password) or die(mysql_error());
Task.all.each do |t|
puts "Processing task [#{t.id}]"
t.title = t.title.gsub(/ã/, 'ã').gsub(/á/, 'á').gsub(/ê/, 'ê').gsub(/é/, 'é').gsub(/à /, 'í').gsub(/ó/, 'ó').gsub(/õ/, 'õ').gsub(/ú/, 'ú').gsub(/ç/, 'ç').gsub(/Ã/, 'à')
t.description = t.description.gsub(/ã/, 'ã').gsub(/á/, 'á').gsub(/ê/, 'ê').gsub(/é/, 'é').gsub(/à /, 'í').gsub(/ó/, 'ó').gsub(/õ/, 'õ').gsub(/ú/, 'ú').gsub(/ç/, 'ç').gsub(/Ã/, 'à')
t.save
end
FieldValue.all.each do |f|
puts "Processing field value [#{f.id}]"
User.all.each do |u|
puts "Processing user [#{u.id}]"
if u.name.present?
u.name = u.name.gsub(/ã/, 'ã').gsub(/á/, 'á').gsub(/ê/, 'ê').gsub(/é/, 'é').gsub(/à /, 'í').gsub(/ó/, 'ó').gsub(/õ/, 'õ').gsub(/ú/, 'ú').gsub(/ç/, 'ç').gsub(/Ã/, 'à')
u.save
end
end