Skip to content

Instantly share code, notes, and snippets.

@saidimu
saidimu / gist:1644333
Created January 20, 2012 01:22 — forked from mbrochh/gist:982495
First version of GetClientInfoView
"""View classes for the get_client_info application."""
from shop.views import ShopTemplateView
from shop.views.checkout import SelectShippingView
class GetClientInfoView(SelectShippingView):
"""Displays form for gathering shipping and billing address."""
@saidimu
saidimu / gist:1644338
Created January 20, 2012 01:22 — forked from mbrochh/gist:980463
settings for django-shop backends
SHOP_SHIPPING_FLAT_RATE = '-30'
SHOP_SHIPPING_BACKENDS = [
'shop.shipping.backends.flat_rate.FlatRateShipping',
]
SHOP_PAYMENT_BACKENDS = [
'shop.payment.backends.pay_on_delivery.PayOnDeliveryBackend'
]
@saidimu
saidimu / gist:1644342
Created January 20, 2012 01:22 — forked from mbrochh/gist:979145
Admin model for django-shop
from django.contrib import admin
from myshop import models as shop_models
class LEDAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("name",)}
admin.site.register(shop_models.Category)
admin.site.register(shop_models.Distributor)
@saidimu
saidimu / gist:1644343
Created January 20, 2012 01:23 — forked from mbrochh/gist:979127
Product models for django-shop
from django.db import models
from shop.models.productmodel import Product
class Category(models.Model):
"""Master data: Names of categories."""
name = models.CharField(max_length=256)
def __unicode__(self):
return self.name
@saidimu
saidimu / ka_bnet_numpy.py
Created March 28, 2012 17:27 — forked from kohlmeier/ka_bnet_numpy.py
Bayes net example in Python with Khan Academy data
#!/usr/bin/env python
from numpy import asmatrix, asarray, ones, zeros, mean, sum, arange, prod, dot, loadtxt
from numpy.random import random, randint
import pickle
MISSING_VALUE = -1 # a constant I will use to denote missing integer values
def impute_hidden_node(E, I, theta, sample_hidden):
@saidimu
saidimu / .jshintrc
Created November 13, 2012 16:52 — forked from haschek/.jshintrc
JSHint Configuration, Strict Edition
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true
@saidimu
saidimu / gist:4080665
Created November 15, 2012 19:29 — forked from ligfx/gist:1366208
monkeypatch socket.io to work with nginx with buffering on (e.g. dotcloud)
var monkeypatch = function(io) {
io.configure(function(){
io.set("transports", ["xhr-polling"]);
io.set("polling duration", 10);
});
io.handleRequest = _.wrap(io.handleRequest, function(next, req, res) {
res.writeHead = _.wrap(res.writeHead, function(next, status, headers) {
if (headers) { delete headers.Connection; }
return next.call(this, status, headers);
});
@saidimu
saidimu / README
Created November 23, 2012 05:22 — forked from jpetazzo/README
autobahn websocket on dotCloud
Autobahn on dotCloud!
This code is 99% Autobah example code, 1% dotCloud adaptation.
To test this on dotCloud:
- create a dotCloud account at http://www.dotcloud.com/
(free, no credit card)
- install dotCloud CLI, see http://docs.dotcloud.com/
def run_pg_fouine():
info = host_info[env.host_string]
db_name = info.tags.get('Name')
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 0/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
time.sleep(30)
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 500/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
run('tail -n 100000 /var/log/postgresql/postgresql-9.*-main.log > /tmp/pgfouine.txt')
run('gzip -f /tmp/pgfouine.txt')
@saidimu
saidimu / .jshintrc
Created December 19, 2012 22:10 — forked from haschek/.jshintrc
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true