Skip to content

Instantly share code, notes, and snippets.

Aziz M. Bookwala azizmb

Block or report user

Report or block azizmb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
azizmb /
Created Jan 7, 2012
Scrapy pipeline to enque scraped items to message queue using carrot
from scrapy.xlib.pydispatch import dispatcher
from scrapy import signals
from scrapy.exceptions import DropItem
from scrapy.utils.serialize import ScrapyJSONEncoder
from carrot.connection import BrokerConnection
from carrot.messaging import Publisher
from twisted.internet.threads import deferToThread
azizmb /
Last active Jan 4, 2016
Simple shell which initializes a connection to Rackspace CloudFiles
import argparse
import cloudfiles
from cloudfiles.connection import Connection
AUTH_URLS = ['uk_authurl', 'us_authurl']
if __name__ == '__main__':

Prevent laptop from suspending when lid is shut


sudo systemctl stop systemd-logind && sudo systemctl start systemd-logind
azizmb /
Created Jan 2, 2013
Script to test the status for a bunch of urls, with aggregate counts in the end. Usage: python file_with_404_links.txt
import sys
from collections import defaultdict
import requests
file_name = sys.argv[1]
results = defaultdict(list)
with open(file_name) as f:
azizmb /
Created Nov 22, 2015
Simple script to sync templates across two mandrill accounts.
import optparse
from mandrill import Mandrill
from mandrill import UnknownTemplateError
def sync_templates(source_key, destination_key, update_existing=True, dry_run=False):
def perform_action(action):
'''Simple wrapper to skip actaully doing anything if dry run is enabled.
azizmb /
Created Aug 29, 2012
A pattern for implementing RESTfull nested resources in Django
from django.conf.urls import patterns, url
from django.contrib.contenttypes.models import ContentType
from appname1.views import PostListView, PostDetailView, \
PostCreateView, PostDeleteView, PostUpdateView
from appname2.views import CommentListView,\
CommentDetailView, CommentCreateView, CommentDeleteView, \
from models import Post
View fb_init.html
<div id="fb-root"></div>
var fbAppId = '< APP ID >';
var fbInitFuncs = [];
var fbInitialized = false;
window.fbAsyncInit = function() {
View 0_instructions.txt
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
filesystem will be different but this guide will get you working with it
while we wait for all that to finalize.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
It's based on eric1234 gist ijust made it 3.1 compliant in terms of convention
azizmb / carmen_country_input.rb
Created May 18, 2012
Carmen Country input field for SimpleForm
View carmen_country_input.rb
class CarmenCountryInput < SimpleForm::Inputs::PriorityInput
def input
@builder.send(:"country_select", attribute_name, input_options, input_html_options)
azizmb / _notification.html.haml
Created Apr 25, 2012
Bootstrap flash messages
View _notification.html.haml
- flash.each do |type, message|
.alert.alert-block{:class => "alert-#{bootstrap_alert_type(type)}" }
%h4.alert-heading #{ bootstrap_alert_type(type).titleize }!
= message
You can’t perform that action at this time.