Skip to content

Instantly share code, notes, and snippets.

View defbyte's full-sized avatar

Chris Davis defbyte

View GitHub Profile
@lukeman
lukeman / gist:386835
Created May 2, 2010 02:14
Example of using django-sorting, django-filter and django-pagination together
{% load pagination_tags %}
{% load sorting_tags %}
{% block body %}
{% autosort filter.qs as sorted_objects %}
{% autopaginate sorted_objects 10 as object_list %}
{% for object in object_list %}
{{ object }}
@jsummerfield
jsummerfield / gist:1486891
Created December 16, 2011 17:00
Amazon SES SMTP support for Django
"""
Django's SMTP EmailBackend doesn't support an SMTP_SSL connection necessary to interact with Amazon SES's newly announced SMTP server. We need to write a custom EmailBackend overriding the default EMailBackend's open(). Thanks to https://github.com/bancek/django-smtp-ssl for the example.
"""
--- settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'email-smtp.us-east-1.amazonaws.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = 'username'
@Nearhan
Nearhan / Drop & Cascade Tables
Last active December 11, 2015 16:19
Drops and Cascades all tables in Django
python manage.py sqlclear myapp auth sites sessions contenttypes | sed 's/";/" CASCADE;/' | python manage.py dbshell
@gmac
gmac / csv-parser
Last active December 17, 2015 13:59
CSV Parser
function parseCSV(csv, delimiter) {
delimiter = (delimiter || ",");
var pattern = new RegExp("(\\"+ delimiter +"|\\r?\\n|\\r|^)"+"(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|"+"([^\"\\"+ delimiter +"\\r\\n]*))", "gi");
var quote = new RegExp("\"\"", "g");
var data = [[]];
var matches = null;
var val, d;
while (matches = pattern.exec(csv)) {
@gmac
gmac / simple-ajax
Last active December 17, 2015 15:10
API: ajax('url', callbackFunction?, postData?); --> returns: a handle object with an ".abort();" method for canceling the request.
var ajax = (function( root ) {
function getRequest() {
if (root.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
else if (root.XMLHttpRequest) return new XMLHttpRequest();
else return null;
}
return function(url, callback, post) {
post = post || "";
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@0xabad1dea
0xabad1dea / singularthey.md
Last active June 18, 2022 18:01
Singular They in Technical English

Guidelines for Singular They in Technical English

by 0xabad1dea, December 2014

This document is an RFC of sorts for increasing the adoption rate of Singular They in technical English. This is not an ultimatum; this is not shaming anyone who has done otherwise; and this is definitely not applicable to any other language.

What is Singular They?

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@robinsloan
robinsloan / shh.rb
Last active August 18, 2023 12:09
Disable RTs from all the people you follow on Twitter.
require "rubygems"
require "twitter"
# get these from apps.twitter.com
CONSUMER_KEY = "foo"
CONSUMER_SECRET = "bar"
OAUTH_TOKEN = "blee"
OAUTH_TOKEN_SECRET = "baz"
TWITTER_USER = "your_username" # needs to be the one associated with keys above