Skip to content

Instantly share code, notes, and snippets.

View brafales's full-sized avatar

Bernat Ràfales brafales

View GitHub Profile
@brafales
brafales / mysql_DB_clone.rake
Created October 10, 2012 09:22 — forked from ggonnella/mysql_DB_clone.rake
MySQL rake task for rails to copy the content of the production database to the development database. Please note that the current development database will be DROPPED!
namespace :db do
namespace :mysql do
desc "Overwrite the whole development db with a copy of the production db"
task :init_dev do
config = YAML.load(IO.read("config/database.yml"))
d = config["development"]
p = config["production"]
unless ["mysql", "mysql2"].include? d["adapter"] and
@brafales
brafales / mysql_database_size_report
Created October 17, 2013 10:19
Mysql database size report
SELECT table_schema "DB Name",
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables
GROUP BY table_schema;
@brafales
brafales / wtf.rb
Last active December 29, 2015 02:49
WTF of the day
def set_items_quantity(integer)
fact = proc {
if integer < items.length #reduce items
remove_an_item
fact.call
elsif integer > items.length #increase items
add_an_item
fact.call
end
}
@brafales
brafales / right.rb
Last active January 2, 2016 16:49
Inheritance and class variables
class A
class << self
attr_reader :a
end
@a = "a"
end
class B < A
@a = "b"
end
@brafales
brafales / make.log
Last active August 29, 2015 14:02
rvm install 1.9.2-head
[2014-06-04 11:55:04] __rvm_make
__rvm_make ()
{
\make "$@" || return $?
}
current path: /home/bernat/.rvm/src/ruby-1.9.2-head
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/texbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/bernat/local/arena_scripts/shell/../provision/bin:/home/bernat/local/arena_scripts/shell/../bootstrap:/home/bernat/local/arena_scripts/shell/mysql:/home/bernat/local/arena_scripts/shell/deploy:/home/bernat/local/arena_scripts/shell/rsync:/home/bernat/local/arena_scripts/shell/misc:/home/bernat/.rvm/bin
command(2): __rvm_make -j2
++ make -j2
gcc -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -fPIC -I. -I.ext/include/x86_64-linux -I./include -I. -DRUBY_EXPORT -o main.o -c main.c
@brafales
brafales / tiny_mce_toggler.html
Created June 9, 2014 13:25
TinyMCE Toggler example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>TinyMCE - Toggler</title>
<link type="text/css" rel="stylesheet" href="http://moxiecode.cachefly.net/tinymce/v8/css/all.min.css?v=8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="javascript/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
$(function() {
curl --data "param1=%26amp;param2=something" http://localhost:3001
Started POST "/" for 127.0.0.1 at 2014-06-20 14:28:59 +0100
Processing by PageController#route_to_path as */*
Parameters: {"param1"=>"&amp", "param2"=>"something"}
curl --data "param1=<order>V %26amp; A</order>" http://localhost:3001
Started POST "/" for 127.0.0.1 at 2014-06-20 14:29:30 +0100
Verifying that +brafales is my blockchain ID. https://onename.com/brafales

Keybase proof

I hereby claim:

  • I am brafales on github.
  • I am the_bell (https://keybase.io/the_bell) on keybase.
  • I have a public key ASCk-Uae1r4hrpK-_-gXVChCPdjm308RwXaoPfYAKw85qAo

To claim this, I am signing this object:

class NilClass
def method_missing
raise StandardError "Ha, ha! Loser"
end
end