This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hi | |
puts "hi | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# La idea es que cada cuenta tiene un numero, por ej 5. Pero su padre tiene numero 2 y el padre de este tiene numero 1. | |
# Entonces quiero generar el numero en forma: "1.2.5. Cuenta XXX" | |
# Lo que hago es ir subiendo en la recursion hasta llegar a la raiz que es parent.nil? | |
def numero_total | |
if parent.nil? | |
return"#{numero}." | |
else | |
return "" + parent.numero_total | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2 id="titulo_2" align="center">Cifras en pesos</h2> | |
<p style="color: green"><%= flash[:notice] %></p> | |
<p><%= link_to "Volver a menú principal", :controller => "presupuestos" %></p> | |
<% form_tag({:action => "update"}, :id => "presupuesto", :onkeypress => "return event.keyCode!=13;") do %> | |
<p><%= submit_tag "Guardar", :id => "submit", :disabled => true %></p> | |
<h2>Editando centro de costo: <%= "#{@cc.codigo} - #{@cc.nombre}"%></h2> | |
<h3>Estado del centro de costo: <span id ="label_completo" class="doc_incompleto">Incompleto</span></h3> | |
<div id="tabla"> | |
<div style="width:2500px"> | |
<table width="2500"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Begin: code to initialize just one time | |
Nanite.identity = Nanite.gensym | |
AMQP.start :host => 'localhost', :user => 'mapper', :pass => 'testing', | |
:vhost => '/nanite' | |
Nanite.mapper = Nanite::Mapper.new(15) | |
# End code | |
EM.add_timer(16) do | |
Nanite.request("/mock/list", '', :target => 'barney') do |res| | |
p res |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f1 = Factura.first | |
# Quiero saber todos los productos que se han comprado | |
ps = f1.productos | |
p1 = Producto.first | |
# Quiero saber en que facturas aparece este producto | |
fs = p1.facturas | |
# Quiero saber que producto se ha vendido 3 veces y a que factura pertenece | |
r1 = Relacion.first(:cantidad => 3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def format_consecutivo(num) | |
cero = "0" | |
times = 4 - num.to_s.size | |
return cero*times + num.to_s | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------------------- | |
Exception happened during processing of request from ('127.0.0.1', 57005) | |
Traceback (most recent call last): | |
File "/Library/Python/2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/httpserver.py", line 1062, in process_request_in_thread | |
self.finish_request(request, client_address) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/SocketServer.py", line 254, in finish_request | |
self.RequestHandlerClass(request, client_address, self) | |
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/SocketServer.py", line 522, in __init__ | |
self.handle() | |
File "/Library/Python/2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/httpserver.py", line 436, in handle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):001:0> require 'dm-sweatshop' | |
=> true | |
irb(main):002:0> require 'spec/spec_fixtures' | |
=> true | |
irb(main):003:0> Company.make | |
=> #<Company id=nil name="Acme" email_address=nil alternate_email_address=nil street_1="767 Bridgeway" street_2=nil city="Sausalito" state="CA" postal_code="94965" country="USA" phone_number="555-658-0819" created_at=nil updated_at=nil> | |
irb(main):004:0> User.make | |
=> #<User activated_at=nil activation_code=nil id=nil login="ian" company_id=nil first_name="Ian" last_name="Curtis" email_address="[email protected]" alternate_email_address=nil street_1="767 Bridgeway" street_2=nil city="Sausalito" state="CA" postal_code="94965" country="USA" type=nil phone_number="555-658-0819" created_at=nil updated_at=nil role_id=nil crypted_password=nil salt=nil> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> site = RestClient::Resource.new('http://twitter.com', :user => "XXXXXX", :password => "XXXXXX") | |
>> malsano = JSON.parse(site["users/show/almaeffect.json"].get) | |
>> malsano["name"] | |
=> "Ivan SIerra" | |
>> malsano["profile_image_url"] | |
=> "http://s.twimg.com/a/1258056589/images/default_profile_2_normal.png" | |
>> malsano["screen_name"] | |
=> "ALMAEFFECT" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Card | |
attr_accessor :new_employee_id | |
def reassign(employee_id) | |
old_card = self.card_assignments.all(:conditions=>["active_since < #{DateTime.now} and #{DateTime.now} < active_until"]).first | |
if !old_card.nil? | |
old_card.active_until = DateTime.now | |
old_card.save | |
end |
OlderNewer