Skip to content

Instantly share code, notes, and snippets.

View bryanveloso's full-sized avatar

Bryan Veloso bryanveloso

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
// Example of how to cache the result of an external jQuery Template.
// Inspired by this post...
// http://encosia.com/2010/10/05/using-external-templates-with-jquery-templates/
var person = {name: 'Dave'};
var person_tmpl;
$.get('_template.tpl.html', function(template) {
// Use converted string from remote file.
import datetime
import mechanize
from xml.etree import cElementTree
USERNAME = '...'
PASSWORD = '...'
NUMBER = '2025551212'
br = mechanize.Browser()
br.open('https://ebillpay.verizonwireless.com/vzw/accountholder/overview/AccountOverview.action')
from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext
from myapp.models import Note
def note_detail(request, slug):
note = get_object_or_404(Note, slug=slug)
editable = request.user.is_authenticated and request.user.id == note.author.id
return render_to_response('myapp/note_detail.html', {
from haystack.indexes import *
from haystack import site
from cab.models import Snippet
class SnippetIndex(SearchIndex):
text = CharField(document=True, use_template=True)
author = CharField(model_attr='author__username')
title = CharField(model_attr='title')
tags = CharField()
tag_list = MultiValueField()
$.noConflict();
jQuery(document).ready(function($){
$('.audio').each(function(){
var match = $(this).find('script').html().match(/audio_file=(.*)\\x26/);
$(this).find('span').html('<audio src="'+match[1]+'?plead=please-dont-download-this-or-our-lawyers-wont-let-us-host-audio" controls="controls">Your browser does not support the audio element.</audio>').remove();
$(this).find('script').remove();
});
});
@rcrowley
rcrowley / deps.pp
Created November 8, 2010 22:33
Ruby dependency management with Puppet
stage { "pre": before => Stage["main"] }
class pre {
package {
"build-essential": ensure => latest;
"ruby": ensure => "4.5"; # Ruby 1.8.7
"ruby-dev": ensure => "4.5"; # Ruby 1.8.7
"rubygems": ensure => "1.3.7-2";
}
}
class { "pre": stage => "pre" }

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

@ericflo
ericflo / json_session_messages.py
Created November 15, 2010 05:18
Message backend which spits out dictionaries able to be json encoded/decoded, for those session backends which do not pickle.
from django.contrib.messages.storage.base import Message, BaseStorage
class JSONSessionStorage(BaseStorage):
"""
Stores messages in JSON-compatible format
"""
session_key = '_messages'
def _to_dict(self, message):
return {
#some_style
@media (max-width: 320px) &
display: none