Skip to content

Instantly share code, notes, and snippets.

View andres-torres-marroquin's full-sized avatar
🎯
Focusing

Andres Torres andres-torres-marroquin

🎯
Focusing
View GitHub Profile
"""
lockfile.py - Platform-independent advisory file locks.
Requires Python 2.5 unless you apply 2.4.diff
Locking is done on a per-thread basis instead of a per-process basis.
Usage:
>>> lock = LockFile('somefile')
>>> try:
@andres-torres-marroquin
andres-torres-marroquin / gist:1052444
Created June 28, 2011 22:45
Google Chrome splinter 0.1.1
Feature: Going Once, Going Twice. # apps/mainsite/features/going_once_twice_auctions.feature:1
Scenario: In the homepage # apps/mainsite/features/going_once_twice_auctions.feature:3
Given that I have an auction about to be closed # apps/mainsite/features/step_definitions/going.py:6
When I go to the auction page # apps/mainsite/features/step_definitions/going.py:11
Then I see the "GOING ONCE" in the auction timer # apps/mainsite/features/step_definitions/going.py:15
Traceback (most recent call last):
File "/home/atorres/virt_env/virt1/lib/python2.6/site-packages/lettuce/core.py", line 113, in __call__
ret = self.function(self.step, *args, **kw)
File "/home/atorres/Desktop/bidsite/apps/mainsite/features/step_definitions/going.py", line 20, in see_the_text_in_the_timer
@andres-torres-marroquin
andres-torres-marroquin / django-crossdomainxhr-middleware.py
Created March 12, 2012 18:52 — forked from vicalejuri/django-crossdomainxhr-middleware.py
Middlware to allow's your django server to respond appropriately to cross domain XHR (postMessage html5 API).
import re
from django.utils.text import compress_string
from django.utils.cache import patch_vary_headers
from django import http
try:
import settings
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS
def get_profile(user):
if not hasattr(user, '_profile_cache'):
profile, created = UserProfile.objects.get_or_create(user=user)
user._profile_cache = profile
return user._profile_cache
User.get_profile = get_profile
if settings.DEBUG:
urlpatterns += patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT,
}),
)
@andres-torres-marroquin
andres-torres-marroquin / gist:3692402
Created September 10, 2012 17:38
Estúpido Telmex

En Lomas de Morelia, no pueden ofrecerte mas de 1 mbps porque no tienen la infraestructura, pero lo que si pueden hacer es cobrartelo. Idiotas...

HELLO MARROQUIN
I AM MR.JOHN KHAIRI, A CITIZEN OF MALAYSIA ,REGIONAL AUDITOR OF BARCLAYS BANK GHANA BRANCH. I HAVE IN MY BANK THE EXISTENCE OF A BIG AMOUNT OF MONEY VALUED US$8,000,000.00 (EIGHT MILLION US DOLLARS)THAT BELONGS TO A CUSTOMER, MR.DENIS MARROQUIN
AND WHO HAPPEN TO HAVE THE SAME SURNAME AS YOURS .THE FUND IS NOW WITHOUT ANY CLAIM BECAUSE MR. DENIS DIED IN A DEADLY EARTHQUAKE IN CHINA IN 2008 . I WANT YOUR CORPERATION SO AS TO MAKE THE BANK SEND YOU THE FUND AS THE BENEFICIARY AND NEXT OF KIN TO THE FUND.
TRUST PLEASE!
THIS TRANSACTION WILL BE OF A GREAT MUTUAL ASSISTANCE TO US. SEND ME YOUR REPLY OF INTEREST SO THAT I WILL GIVE YOU THE DETAILS.
STRICTLY SEND IT TO MY PRIVATE EMAIL ACCOUNT: johnkhairi01@gmail.com, OR SEND ME
YOUR EMAIL ADDRESS TO SEND YOU DETAILS OF THIS TRANSACTION.
AT THE RECIEPT OF YOUR REPLY, I WILL GIVE YOU DETAILS OF THE TRANSACTION. AND A COPY OF THE DEPOSIT CERTIFICATE OF THE FUND AND ALSO THE INCORPORATION CERTIFICATE OF THE COMPANY THAT GENERATED THE FUND.
(deltamedix)ed@HinduKush:~/projects/deltamedix/deltamedix$ cat /etc/freetds/freetds.conf
# $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".
# Global settings are overridden by those in a database
import datetime
from django import template
register = template.Library()
@register.simple_tag
def get_verbose_name(model, field):
"""
How to use it:
{% get_verbose_name model "field" %}
var asd = function (users) {
var result = [];
while ((result.length + users.length) > 5) {
last4 = users.splice(-4);
result.unshift(last4);
}
return users.concat(result);
};