Skip to content

Instantly share code, notes, and snippets.

View dtran320's full-sized avatar
🌊
Come co-work with us virtually! https://www.flow.club

David Tran dtran320

🌊
Come co-work with us virtually! https://www.flow.club
View GitHub Profile
import redis
from django.conf import settings
from django.core.signals import request_finished
try:
from eventlet.corolocal import local
except ImportError:
from threading import local

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@uogbuji
uogbuji / gruber_urlintext.py
Created November 18, 2010 18:28
John Gruber's regex to find URLs in plain text, converted to Python/Unicode
#See: http://daringfireball.net/2010/07/improved_regex_for_matching_urls
import re, urllib
GRUBER_URLINTEXT_PAT = re.compile(ur'(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?\xab\xbb\u201c\u201d\u2018\u2019]))')
for line in urllib.urlopen("http://daringfireball.net/misc/2010/07/url-matching-regex-test-data.text"):
print [ mgroups[0] for mgroups in GRUBER_URLINTEXT_PAT.findall(line) ]
@dcramer
dcramer / track_data.py
Created December 6, 2010 19:15
Tracking changes on properties in Django
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')
@bohde
bohde / async_manage.py
Created February 11, 2011 02:56
Patch Django with eventlet before it loads any connections
#!/usr/bin/env python
import os
import eventlet
import eventlet.debug
os.environ["EVENTLET_NOPATCH"] = 'True'
eventlet.monkey_patch()
eventlet.debug.hub_prevent_multiple_readers(False)
from django.core.management import execute_manager
diff --git a/djcelery/management/commands/celeryd.py b/djcelery/management/commands/celeryd.py
index cffadf7..3270de3 100644
--- a/djcelery/management/commands/celeryd.py
+++ b/djcelery/management/commands/celeryd.py
@@ -4,10 +4,13 @@ Start the celery daemon from the Django management command.
"""
from celery.bin import celeryd
+from celery.bin.base import Option
//Gruber wrote this regex for matching URLs, but it took a small amount of massage to use it in JavaScript. So here.
//Sauce: http://daringfireball.net/2010/07/improved_regex_for_matching_urls
var p = /\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i;
p.exec('party fun www.twitter.com yay') //winning.
@baijum
baijum / selenium_with_python.rst
Last active April 19, 2024 14:37
Selenium with Python
@mikeyk
mikeyk / gist:1329319
Created October 31, 2011 22:56
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@damian
damian / pre-commit
Created November 18, 2011 16:02
Git pre-commit hook
#!/bin/sh
# A JavaScript focussed git pre-commit hook
#
# It ensures that any files containing console.log() or alert() calls aren't able to be committed.
# It also ensures that all JavaScript passes JSHint(which is assumed to be installed). A static code analysis tool which detects errors and potential issues from smelly JS - see http://www.jshint.com/ for more details
#
# Written by Damian Nicholson - @damian
if git rev-parse --verify HEAD >/dev/null 2>&1