Skip to content

Instantly share code, notes, and snippets.

@azizmb
azizmb / mandrill-sync.py
Created November 22, 2015 10:50
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
azizmb / installing_pil.md
Last active August 29, 2015 14:00
PIL dependencies

Installing libs and fixing lib links

build=`uname --hardware-platform`
apt-get install python-dev libjpeg62 libjpeg-dev libpng12-0 libpng-dev libfreetype6-dev
ln -s /usr/lib/${build}-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/${build}-linux-gnu/libz.so /usr/lib
@azizmb
azizmb / rcloud_console.py
Last active January 4, 2016 22:09
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__':
@azizmb
azizmb / arch.md
Last active December 23, 2015 10:29

Prevent laptop from suspending when lid is shut

/etc/systemd/logind.conf:

HandleLidSwitch=ignore
sudo systemctl stop systemd-logind && sudo systemctl start systemd-logind
@azizmb
azizmb / test_urls.py
Created January 2, 2013 13:45
Script to test the status for a bunch of urls, with aggregate counts in the end. Usage: python test_urls.py 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
azizmb / appname1-urls.py
Created August 29, 2012 13:15
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, \
CommentUpdateView
from models import Post
<div id="fb-root"></div>
<script>
var fbAppId = '< APP ID >';
(function(){
var fbInitFuncs = [];
var fbInitialized = false;
window.fbAsyncInit = function() {
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 https://gist.github.com/911003. ijust made it 3.1 compliant in terms of convention
@azizmb
azizmb / carmen_country_input.rb
Created May 18, 2012 19:24
Carmen Country input field for SimpleForm
class CarmenCountryInput < SimpleForm::Inputs::PriorityInput
def input
@builder.send(:"country_select", attribute_name, input_options, input_html_options)
end
end
@azizmb
azizmb / bootstrap.validator.overrides.js
Created April 25, 2012 18:15
Bootstrap Validator Overrides
$.extend($.validator.messages, {
required: "can't be blank",
remote: 'needs to get fixed',
email: 'is an invalid email address',
url: 'is not a valid URL',
date: 'is not a valid date',
dateISO: 'is not a valid date (ISO)',
number: 'is not a valid number',
digits: 'needs to be digits',
creditcard: 'is not a valid credit card number',