This file contains 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 fake_complexity(number) | |
puts "Launching very smart computation with the most clever algorithm...." | |
sleep(1) | |
puts ".." | |
sleep(1) | |
puts "...." | |
sleep(1) | |
puts "......." | |
result = yield(number, 4) |
This file contains 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 greet(arg1, arg2, name) | |
puts "#{arg1} ---- #{arg2} #{yield(name)}" | |
end | |
me = 'John' | |
greet(1, 2, me) { |name| "Hello #{name}" } | |
greet(1, 2, me) { |name| "Bonjour #{name}" } |
This file contains 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
{ | |
"name": "Paris", | |
"population": 2211000 | |
} |
This file contains 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
--- a/hitcount/templatetags/hitcount_tags.py | |
+++ b/hitcount/templatetags/hitcount_tags.py | |
@@ -153,7 +153,7 @@ class GetHitCountJavascript(template.Node): | |
obj, created = HitCount.objects.get_or_create(content_type=ctype, | |
object_pk=object_pk) | |
- js = "$.post( '" + reverse('hitcount_update_ajax') + "'," + \ | |
+ js = "jQuery.post( '" + reverse('hitcount_update_ajax') + "'," + \ | |
"\n\t{ hitcount_pk : '" + str(obj.pk) + "' },\n" + \ | |
"\tfunction(data, status) {\n" + \ |
This file contains 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
from django.db.models.signals import post_init | |
def track_data(*fields): | |
""" | |
Tracks property changes on a model instance. | |
The changed list of properties is refreshed on model initialization | |
and save. | |
>>> @track_data('name') |
This file contains 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
--- | |
:update_sources: true | |
:sources: | |
- https://rubygems.org | |
:benchmark: false | |
:bulk_threshold: 1000 | |
:backtrace: false | |
:verbose: true | |
gem: --no-ri --no-rdoc |
This file contains 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
<div class="wide1_left"> | |
<a class="sublime" href="{{ MEDIA_URL }}video/2day4ever_presentation.mp4"> | |
<img src="{{ MEDIA_URL }}img/video_home.jpg" alt="Lancer la video" /> | |
</a> | |
<video style="display:none" class="sublime zoom" width="800" height="450" preload="none"> | |
<source src="{{ MEDIA_URL }}video/2day4ever_presentation.mp4" type='video/mp4'> | |
</video> | |
</div> |
This file contains 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
module Main where | |
type Radius = Double | |
type Side = Double | |
data Shape = | |
Point | |
| Circle Radius | |
| Rectangle Side Side | |
| Square Side | |
area Point | |
area (Circle r) =pi*r*r area (Rectangle w h) = w * h |
This file contains 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
require 'benchmark' | |
Benchmark.measure { Callbacks::ShoesProduct::Update.perform 29 } | |
# sibling_color_slug = {} | |
# variants_stock_availability = {} | |
# no specific update_siblings_of() for ShoesProduct | |
# sibling_ids: product.available_siblings.map(&:id), | |
# available: product.available?, | |
# displayable: product.displayable?, | |
# out_of_stock: product.out_of_stock?, |
This file contains 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
require 'singleton' | |
# outputs a colored call-trace graph to the Rails logger of the lines of ruby code | |
# invoked during a single request. | |
# | |
# Example: | |
# | |
# 1) Make sure this file is loaded in an initializer | |
# | |
# 2) Add the following to your application.rb in Rails3: |
OlderNewer