Skip to content

Instantly share code, notes, and snippets.

@roadsideseb
roadsideseb / oscar_override_app.py
Created January 24, 2013 12:48
This is an unfinished managment command that I use when customising one of Oscar's core apps. It simply copies over all the files of the app (excluding subdirectories) and leaves the rest to you. I'd like to improve it at some point and make it part of Oscar but I didn't have the time for that yet. The command in action might look like this: ```…
import os
import imp
import shutil
import pkgutil
import logging
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
@roadsideseb
roadsideseb / gist:5127613
Created March 10, 2013 08:20
ZenPhoto / nginx config
server {
server_name domain.tld;
root /var/www/zenphoto;
index index.php;
# pass the PHP scripts to php-fpm server
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
@roadsideseb
roadsideseb / generic.py
Created March 11, 2013 03:20
SearchView wrapper for haystack to bring it in line with Django 1.3+ CBV
from functools import update_wrapper
from django.conf import settings
from django.utils.decorators import classonlymethod
from django.views.generic.base import TemplateResponseMixin
from haystack.query import SearchQuerySet
from haystack.forms import FacetedSearchForm
from haystack.views import FacetedSearchView as HaystackFacetedSearchView
@roadsideseb
roadsideseb / 0002_datamigration.py
Created July 23, 2013 01:45
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…
from myproject.utils import loaddata
class Migration(DataMigration):
def forwards(self, orm):
loaddata(orm, 'some_fancy_fixture.json')
#!/usr/bin/env ruby
# workaround-upstart-snafu
#
# When lied to about the behavior of a job’s main process wrt. forking with the
# “expect” stanza, Upstart can get into a confused state where it’s tracking a
# nonexistent pid.
#
# This hack creates new short-lived processes until one gets the pid in
# question, then has its parent die so that it’s going to get reaped by pid 1
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>
======================================================================
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
@roadsideseb
roadsideseb / the_mobifier.py
Created June 1, 2014 07:16
What does the MobifyBlog say about what an employee at Mobify is called?
# -*- coding: utf-8 -*-
from __future__ import print_function
import re
import feedparser
from collections import defaultdict
MOBIF_REGEX = re.compile(r'(?i)mobif\w+')
@roadsideseb
roadsideseb / Makefile
Last active January 26, 2016 23:07
Deploying image to tutum.
.PHONY: deploy build static-upload
SHELL := /bin/bash
base_image := elbaschid/python-base
builder_image := elbaschid/django-builder
tester_image := elbaschid/django-tester
image := tutum.co/elbaschid/love-fear
image_version := $(shell python deployer.py bump_version)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.