Skip to content

Instantly share code, notes, and snippets.

View dcaliri's full-sized avatar

Diego Caliri dcaliri

  • Eventioz
  • Mendoza, Argentina
View GitHub Profile
@dcaliri
dcaliri / gist.rb
Last active August 29, 2015 13:55
class Bill
def assign_rps_number_and_serial(save_it = nil)
rps = Bill.order(:rps_serial, :rps_number).where('rps_number IS NOT NULL').select(:rps_number, :rps_serial).last
number = rps.try(:rps_number) || 1
serial = rps.try(:rps_serial) || 'A'
self.rps_number, self.rps_serial = if number < 999999999999
[number + 1, serial]
else
[1, serial + 'A']
@dcaliri
dcaliri / nginx.conf
Created October 15, 2014 01:58
/etc/nginx/nginx.conf
# This conf sample is fetched from http://unicorn.bogomips.org/examples/nginx.conf
worker_processes 4;
user root;
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log warn;
events {
diff --git a/app/models/registration.rb b/app/models/registration.rb
index ac4c0e7..823f956 100644
--- a/app/models/registration.rb
+++ b/app/models/registration.rb
@@ -962,12 +962,15 @@ class Registration < ActiveRecord::Base
self.country == country
end
- def can_be_cancelled_by_attendee?
- # we can't cancel a registration that has been more than 7 days from creation
def morse(s)
dictionary = { 'a' => '.-', 'b' => '-...', 'c' => '-.-.', 'd' => '-..', 'e' => '.', 'f' => '..-.', 'g' => '--.', 'h' => '....', 'i' => '..', 'j' => '.---', 'k' => '-.-', 'l' => '.-..', 'm' => '--', 'n' => '-.', 'o' => '---', 'p' => '.--.', 'q' => '--.-', 'r' => '.-.', 's' => '...', 't' => '-', 'u' => '..-', 'v' => '...-', 'w' => '.--', 'x' => '-..-', 'y' => '-.--', 'z' => '--..' }
word = ''
s.downcase!
for i in 0..(s.length - 1) do
if dictionary[s[i,1]]
word << dictionary[s[i,1]]
elsif s[i,1] == ' '
word << ' '
end
def morse(s)
dictionary = { 'a' => '.-', 'b' => '-...', 'c' => '-.-.', 'd' => '-..', 'e' => '.', 'f' => '..-.', 'g' => '--.', 'h' => '....', 'i' => '..', 'j' => '.---', 'k' => '-.-', 'l' => '.-..', 'm' => '--', 'n' => '-.', 'o' => '---', 'p' => '.--.', 'q' => '--.-', 'r' => '.-.', 's' => '...', 't' => '-', 'u' => '..-', 'v' => '...-', 'w' => '.--', 'x' => '-..-', 'y' => '-.--', 'z' => '--..', '0' => '-----', '1' => '.----', '2' => '..---', '3' => '...--', '4' => '....-', '5' => '.....', '6' => '-....', '7' => '--...', '8' => '---..', '9' => '----.' }
word = ''
s.downcase!
for i in 0..(s.length - 1) do
if dictionary[s[i,1]]
word << dictionary[s[i,1]]
elsif s[i,1] == ' '
word << ' '
end
def morse(s)
dictionary = { 'a' => '.-', 'b' => '-...', 'c' => '-.-.', 'd' => '-..', 'e' => '.', 'f' => '..-.', 'g' => '--.', 'h' => '....', 'i' => '..', 'j' => '.---', 'k' => '-.-', 'l' => '.-..', 'm' => '--', 'n' => '-.', 'o' => '---', 'p' => '.--.', 'q' => '--.-', 'r' => '.-.', 's' => '...', 't' => '-', 'u' => '..-', 'v' => '...-', 'w' => '.--', 'x' => '-..-', 'y' => '-.--', 'z' => '--..', '0' => '-----', '1' => '.----', '2' => '..---', '3' => '...--', '4' => '....-', '5' => '.....', '6' => '-....', '7' => '--...', '8' => '---..', '9' => '----.' }
word = ''
s.downcase!
for i in 0..(s.length - 1) do
if dictionary[s[i,1]]
word << dictionary[s[i,1]]
elsif s[i,1] == ' '
word << ' '
end
def test_form_for_deprecated
assert_deprecated do
form_for(:post, @post, :html => { :id => 'create-post' }) do |f|
concat f.label(:title) { "The Title" }
concat f.text_field(:title)
concat f.text_area(:body)
concat f.check_box(:secret)
concat f.submit('Create post')
end
end
def test_form_for
form_for(@post, :as => :post, :html => { :id => 'create-post' }) do |f|
concat f.label(:title)
concat f.text_field(:title)
concat f.text_area(:body)
concat f.check_box(:secret)
concat f.submit('Create post')
end
expected =
<"<form method=\"post\" action=\"http://www.example.com\" id=\"create-post\" accept-charset=\"UTF-8\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" value=\"&#x2713;\" type=\"hidden\" /></div><label for=\"post_title\">The Title</label><input name=\"post[title]\" size=\"30\" id=\"post_title\" value=\"Hello World\" type=\"text\" /><textarea name=\"post[body]\" id=\"post_body\" rows=\"20\" cols=\"40\">Back to the hill and over it again!</textarea><input name=\"post[secret]\" value=\"0\" type=\"hidden\" /><input checked=\"checked\" name=\"post[secret]\" id=\"post_secret\" value=\"1\" type=\"checkbox\" /><input name=\"commit\" id=\"post_submit\" value=\"Create post\" type=\"submit\" /></form>"> expected to be == to
<"<form class=\"post_edit\" method=\"post\" action=\"/posts/123\" id=\"create-post\" accept-charset=\"UTF-8\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" value=\"&#x2713;\" type=\"hidden\" /><input name=\"_method\" value=\"put\" type=\"hidden\" /></div><l
@dcaliri
dcaliri / .vimrc
Created November 18, 2010 13:46
The vimrc I'm using right now
"Fabio Kung <fabio.kung@gmail.com>
"
"Use Vim settings, rather then Vi settings (much better!).
"This must be first, because it changes other options as a side effect.
set nocompatible
"allow backspacing over everything in insert mode
set backspace=indent,eol,start
"store lots of :cmdline history