Skip to content

Instantly share code, notes, and snippets.

View reu's full-sized avatar

Rodrigo Navarro reu

View GitHub Profile
(function(){
//Adcionando o método digaOla para a classe Date
Date.prototype.digaOla = function() {
var hora = this.getHours();
if(hora > 00 && hora <= 06)
return "Boa madrugada";
else if(hora > 06 && hora <= 12)
return "Bom dia";
else if(hora > 12 && hora <= 18)
- form_for @products do |form|
%h3== Specifications
%ul#specifications_container
- form.fields_for :specifications do |specification_form|
= render :partial => "specification", :locals => { :form => specification_form }
%p= add_child_link "Add Specification", :specifications
= new_child_fields_template form, :specifications
@reu
reu / edit.html.erb
Created May 12, 2010 19:06
Custom attributes using serialization
<% form_for(@user) do |f| %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<% f.fields_for :custom, @user.custom do |custom_form| %>
<% custom_form.object.marshal_dump.each_key do |custom_field| %>
<p>
<%= custom_form.label custom_field %><br />
# Classic approach
def check_for_truth
has_at_least_one_true = false # ewwww temp var
[false, false, true].each do |option|
has_at_least_one_true = option
end
has_at_least_one_true
end
require "rubygems"
require "ldap"
require "net/ldap"
email = "[email protected]"
password = "secret"
host = "bluepages.ibm.com"
treebase = "ou=bluepages, o=ibm.com"
filter = "(&(objectClass=person)(mail=#{email}))"