Skip to content

Instantly share code, notes, and snippets.

--- 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" + \
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')
@tgautier
tgautier / .gemrc
Last active September 26, 2015 23:17
My gemrc
---
:update_sources: true
:sources:
- https://rubygems.org
:benchmark: false
:bulk_threshold: 1000
:backtrace: false
:verbose: true
gem: --no-ri --no-rdoc
<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>
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
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?,
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:
git config --global alias.ksreview '!f() { local SHA=${1:-HEAD}; local BRANCH=${2:-master}; if [ $SHA == $BRANCH ]; then SHA=HEAD; fi; git difftool -y -t Kaleidoscope $BRANCH...$SHA; }; f'

If you're writing web applications with Ruby there comes a time when you might need something a lot simpler, or even faster, than Ruby on Rails or the Sinatra micro-framework. Enter Rack.

Rack describes itself as follows:

Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.

Before Rack came along Ruby web frameworks all implemented their own interfaces, which made it incredibly difficult to write web servers for them, or to share code between two different frameworks. Now almost all Ruby web frameworks implement Rack, including Rails and Sinatra, meaning that these applications can now behave in a similar fashion to one another.

At it's core Rack provides a great set of tools to allow you to build the most simple web application or interface you can. Rack applications can be written in a single line of code. But we're getting ahead of ourselves a bit.

@tgautier
tgautier / gist:4659103
Created January 28, 2013 21:17
From jQuery to Backbone

Step by step from jQuery to Backbone

I've seen many struggle when they first meet Backbone.js. In this blog post I will gradually refactor a bit of code from how I used to write JavaScript before, into proper Backbone.js code using models, collections, views and events. Hopefully this process will give you a firm understanding of the core abstractions in Backbone.js.