Skip to content

Instantly share code, notes, and snippets.

View simonbowen's full-sized avatar
🤡

Simon Bowen simonbowen

🤡
View GitHub Profile
@simonbowen
simonbowen / gist:a8316fe91c78b8464402
Created January 28, 2015 10:45
Query Testing Database
# ************************************************************
# Sequel Pro SQL dump
# Version 4096
#
# http://www.sequelpro.com/
# http://code.google.com/p/sequel-pro/
#
# Host: 127.0.0.1 (MySQL 5.5.38-0ubuntu0.14.04.1)
# Database: CampaignText
# Generation Time: 2015-01-28 10:44:05 +0000
@simonbowen
simonbowen / xmpp.py
Created September 29, 2013 21:02
SleekXMPP and gevent
import sleekxmpp
import gevent
import sqlite3
class Message(sleekxmpp.ClientXMPP):
def __init__(self, jid, password):
super(Message, self).__init__(jid, password)
self.add_event_handler('session_start', self.start)
$(function(){
var products = [
{name: 'iPad', description: 'iPad', price: 300, applecare: 50, insurance: 60},
{name: 'ipad2', description: 'ipad2', price: 350, applecare: 55, insurance: 65}
];
// Then build the table from the Javascript array/object
var table = $('table');
for(x=0; x<products.length; x++){
var tr = $('<tr>');
php_flag display_errors on
php_flag display_startup_errors on
php_value error_reporting 2047
php_value upload_max_filesize 20M
php_value post_max_size 20M
AuthType Basic
AuthName "Restricted Area"
AuthUserFile "/var/www/vhosts/myfonedev.co.uk/.htpasswds/.htpasswd"
require valid-user
public function format_message(array $message, $format = "time --- level: body in file:line")
{
$message['time'] = Date::formatted_time('@'.$message['time'], Log_Writer::$timestamp, Log_Writer::$timezone, TRUE);
$message['level'] = $this->_log_levels[$message['level']];
$string = strtr($format, array_filter($message, 'is_scalar'));
if (isset($message['additional']['exception']))
{
// Re-use as much as possible, just resetting the body to the trace
@simonbowen
simonbowen / gist:5160750
Created March 14, 2013 11:47
Why Shopify Is Bad

Documentation

The documentation for shopify is horrendous, there are filters and various other undocumented features that I found in the Liquid template documentation.

Hard to find out how to customise certain areas of the shopify front end. Such as the customer login areas.

Check out Process

This is the worst part, you cannot specify your own HTML for ANY of the checkout pages. You have to rely on CSS to try and style these pages. What makes it even more of a headache is Shopify only gives you terrible markup, nasty use of tables, ID's and classes through out.

#!/bin/bash
#
# Install Postgres 9.1, PostGIS and create PostGIS template on a clean Ubuntu 11.10 Oneiric Ocelot box
# http://wildfish.com
# add the ubuntu gis ppa
sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
{% extends "parent.html" %}
{% block title %}Child Template{% endblock %}
{% block container %}Some page content{% endblock %}
@simonbowen
simonbowen / example_checkboxselectmultiple_render.py
Last active December 12, 2015 06:18
How to customise output of the CheckboxSelectMultiple in Django. I was being a pleb and didn't quite get it at first
### Form, I was originally using a ModelForm, so that's what I shall demonstrate here
class Author(models.Model):
books = models.ManyToManyField(Book)
class AuthorForm(forms.ModelForm):
class Meta:
model = Author
def __init__(self, *args, **kwargs):
@simonbowen
simonbowen / text.php
Created April 27, 2011 18:19
Auto Link Twitter Replies Kohana 3.x
<?php defined('SYSPATH') or die('No direct script access.');
class Text extends Kohana_Text {
public static function auto_twitter($text)
{
return preg_replace('#@([\\d\\w]+)#', '<a href="http://twitter.com/$1">$0</a>', $text);
}
}