Skip to content

Instantly share code, notes, and snippets.

Avatar

Diego Caliri dcaliri

View GitHub Profile
View new_rules.diff
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
@dcaliri
dcaliri / nginx.conf
Created Oct 15, 2014
/etc/nginx/nginx.conf
View 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 {
View gist.rb
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']
View gist:1390165
#user_nav
- if user_signed_in?
Signed in as #{current_user.email}. Not you?
\#{link_to "Sign out", destroy_user_session_path}
- else
= link_to "Sign up", new_user_registration_path
or
\#{link_to "Sign in", new_user_session_path}
View gist:825844
reseller_login /reseller_login {:action=>"login", :controller=>"resellers"}
reseller_join /reseller_join {:action=>"new", :controller=>"resellers"}
reseller_welcome /reseller_welcome {:action=>"welcome", :controller=>"resellers"}
reseller_thanks /reseller_thanks {:action=>"thanks", :controller=>"resellers"}
reseller_activate /reseller_activate/:activation_code {:action=>"activate", :controller=>"re
@dcaliri
dcaliri / .vimrc
Created Nov 18, 2010
The vimrc I'm using right now
View .vimrc
"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
View gist:550334
<"<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
View gist:550250
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
View gist:550248
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 =
View gist:432174
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
You can’t perform that action at this time.