Skip to content

Instantly share code, notes, and snippets.

<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery("#subm > *").hover(function() {
jQuery(this).animate({ paddingLeft: '20px' }, 250);
}, function() {
jQuery(this).animate({ paddingLeft: 0 }, 250);
});
});
def get_turn(self):
print self.Name,'Tu turno'
while True:
a = self._comer_si_puede()
self.log.wrt(str(a))
if a:
return a
return self._aleatorio()
def _comer_si_puede(self):
@enriqueaf
enriqueaf / capicua.py
Created November 29, 2010 18:38
Conseguir un número capicúa através de la suma de inversos y que cumpla la primera propiedad
import time
def es_capicua(numero):
snumero=str(numero)
for i in range(int(len(snumero)/2)):
if snumero[i] != snumero[-i-1]:
return False
return True
def sum_inverso(numero):
#Cramos inverso
@enriqueaf
enriqueaf / gist:1064661
Created July 5, 2011 11:12
Error in HAIZEA when changing interval wake-up time
Traceback (most recent call last):
File "/home/enrique/Projects/haizea/bin/haizea", line 12, in <module>
c.run()
File "/home/enrique/Projects/haizea/src/haizea/cli/commands.py", line 114, in run
config = HaizeaConfig.from_file(configfile)
File "/home/enrique/Projects/haizea/src/haizea/common/config.py", line 149, in from_file
cfg = cls(c)
File "/home/enrique/Projects/haizea/src/haizea/core/configfile.py", line 901, in __init__
Config.__init__(self, config, self.sections)
File "/home/enrique/Projects/haizea/src/haizea/common/config.py", line 67, in __init__
@enriqueaf
enriqueaf / gist:1069712
Created July 7, 2011 15:06
Error: Rescheduling a suspended VM
[2011-07-07 17:05:25.75] LSCHED Next request in the queue is lease 1. Attempting to schedule...
[2011-07-07 17:05:25.75] LEASES __________________________________________________
[2011-07-07 17:05:25.75] LEASES Lease ID : 1
[2011-07-07 17:05:25.75] LEASES Type : Best-effort
[2011-07-07 17:05:25.75] LEASES Submission time: 2011-07-07 17:03:56.00
[2011-07-07 17:05:25.75] LEASES Start : REQ: Unspecified | SCH: None | ACT: 2011-07-07 17:04:23.02
[2011-07-07 17:05:25.75] LEASES Duration : REQ: 01:00:00.00 | ACC: 00:00:58.00 | ACT: None | KNW: None
[2011-07-07 17:05:25.75] LEASES Deadline : None
[2011-07-07 17:05:25.75] LEASES State : Suspended-Queued
[2011-07-07 17:05:25.75] LEASES Resource req : {1: Disk: [0] | CPU: [100] | Memory: [128]}
@enriqueaf
enriqueaf / gist:1069830
Created July 7, 2011 15:55
Haizea Error: Problem when Host of CPU:8 and running VM needding CPU:8
[2011-07-07 17:53:26.86] ENACT.ONE.INFO Fetching nodes from OpenNebula
[2011-07-07 17:53:26.87] ENACT.ONE.INFO Fetched node 1 tenorio Disk: [80000] | CPU: [100, 100, 100, 100, 100, 100, 100, 100] | Memory: [16384.0]
[2011-07-07 17:53:26.87] ENACT.ONE.INFO Fetched 1 nodes from OpenNebula
[2011-07-07 17:53:26.87] RM Starting resource manager
[2011-07-07 17:53:26.87] RPCSERVER RPC server started on port 42493
[2011-07-07 17:53:26.87] CLOCK Starting clock
[2011-07-07 17:53:26.87] CLOCK Waking up to manage resources
[2011-07-07 17:53:26.87] CLOCK Wake-up time recorded as 2011-07-07 17:53:27.00
[2011-07-07 17:53:26.88] VMSCHED We have to free all this space {node => space}
[2011-07-07 17:53:26.88] VMSCHED Nothing to see
@enriqueaf
enriqueaf / gist:1071911
Created July 8, 2011 14:07
Haizea error: No running handleEndShutdown in ONE mode
[2011-07-08 16:00:27.03] CLOCK Going back to sleep. Waking up at 2011-07-08 16:00:47.00 to handle slot table event.
[2011-07-08 16:00:47.01] CLOCK Waking up to manage resources
[2011-07-08 16:00:47.01] CLOCK Wake-up time recorded as 2011-07-08 16:00:47.00
[2011-07-08 16:00:47.01] VMSCHED LEASE-1 Start of handleEndVM
[2011-07-08 16:00:47.01] VMSCHED LEASE-1 Before:
[2011-07-08 16:00:47.01] LEASES __________________________________________________
[2011-07-08 16:00:47.01] LEASES Lease ID : 1
[2011-07-08 16:00:47.01] LEASES Type : Best-effort
[2011-07-08 16:00:47.01] LEASES Submission time: 2011-07-08 15:58:34.00
[2011-07-08 16:00:47.01] LEASES Start : REQ: Unspecified | SCH: None | ACT: 2011-07-08 15:58:47.01
@enriqueaf
enriqueaf / gist:1317935
Created October 26, 2011 21:28
First try for middleman and pjax
paths_for_url('/guides/*').each do |url|
get(url) do |p|
page "/pjax/guides/#{p}", :proxy=>"/guides/#{p}",:layout=>"pjax"
end
end
@enriqueaf
enriqueaf / .htaccess
Created October 28, 2011 16:19
Apache .htaccess using PJAX
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:X-PJAX} true
RewriteRule ^guides/(.+) /pjax/guides/$1/index.html
Spree::CheckoutController.class_eval do
alias_method :orig_before_payment, :before_payment
protected
def before_delivery
orig_before_delivery
if !flash[:error] && @order.shipments.count == 1 && @order.shipments.first.shipping_rates.count == 1
@order.shipments.first.selected_shipping_rate_id = @order.shipments.first.shipping_rates[0].id