Skip to content

Instantly share code, notes, and snippets.

@roadsideseb
roadsideseb / the_mobifier.py
Created Jun 1, 2014
What does the MobifyBlog say about what an employee at Mobify is called?
View the_mobifier.py
# -*- coding: utf-8 -*-
from __future__ import print_function
import re
import feedparser
from collections import defaultdict
MOBIF_REGEX = re.compile(r'(?i)mobif\w+')
View keybase.md

Keybase proof

I hereby claim:

  • I am elbaschid on github.
  • I am elbaschid (https://keybase.io/elbaschid) on keybase.
  • I have a public key whose fingerprint is C370 5CCB 418A D14A DD16 469D 474F 998F 42CE BD1E

To claim this, I am signing this object:

@roadsideseb
roadsideseb / printable_enum.py
Last active Oct 23, 2015
Make the new Enum class in Python 3.4 (backported as 'enum34') have a printable representation
View printable_enum.py
# -*- encoding: utf-8 -*-
from __future__ import print_function
from enum import Enum
class PrintableValue(object):
def __init__(self, value, printable_name):
self.value = value
self.printable_name = printable_name
@roadsideseb
roadsideseb / compare_assets.py
Created Feb 13, 2014
A little script to pull all assets from 2 URL and compare the found asset URLs as well as their actual content.
View compare_assets.py
#! /usr/bin/env python
import re
import sys
import difflib
import requests
from purl import URL
URL_REGEX = re.compile(
@roadsideseb
roadsideseb / base.html
Created Feb 2, 2014
Oscar packing slip / invoice templates using pisa.
View base.html
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
@page {
size: a4 portrait;
margin: 1cm;
margin-left:2cm;
margin-right:2cm;
@roadsideseb
roadsideseb / views.py
Created Jan 30, 2014
Packing slips for Oscar using PISA in the dashboard
View views.py
from xhtml2pdf import pisa
from xhtml2pdf.pdf import pisaPDF
class OrderListView(ListView, BulkEditMixin):
...
actions = (
'generate_packing_slips',
...
View gist:7245572
======================================================================
ERROR: upload devices from inventory file
----------------------------------------------------------------------
File "/usr/lib/python2.7/unittest/case.py", line 332, in run
testMethod()
File "/home/elbaschid/Worx/Tangent/vodafone/tests/eshop/functional/test_upload_inventory.py", line 114, in test_upload_inventory
after_save_page = save_form.submit().maybe_follow()
File "/home/elbaschid/.virtualenvs/vodafone/local/lib/python2.7/site-packages/webtest/forms.py", line 538, in submit
params=fields, **args)
File "/home/elbaschid/.virtualenvs/vodafone/local/lib/python2.7/site-packages/webtest/response.py", line 293, in goto
View mws_member_list_tests.py
import xml
from boto.mws import response
from boto.handler import XmlHandler
from boto.mws.connection import MWSConnection
from unittest import TestCase
NESTED_MEMBER_LIST_XML = """<GetTestResponse>
@roadsideseb
roadsideseb / 0002_datamigration.py
Created Jul 23, 2013
Using the 'loaddata' management command in a data migration with South is going to break things as soon as the used models change in any way (when running the migrations on a fresh install). The data loaders don't know about the frozen ORM provided by South but use the current state of the models as in the respective 'models.py'. Here's a fixtur…
View 0002_datamigration.py
from myproject.utils import loaddata
class Migration(DataMigration):
def forwards(self, orm):
loaddata(orm, 'some_fancy_fixture.json')
@roadsideseb
roadsideseb / edit.py
Created Apr 9, 2013
MultiFormView for handling multiple forms in a Django CBV with a little more ease...
View edit.py
"""
The following mixins and views are borrowed and adapted from the following
gist:
https://gist.github.com/michelts/1029336
"""
from functools import partial
from django.views.generic.base import TemplateResponseMixin
from django.views.generic.edit import ProcessFormView, FormMixin