Skip to content

Instantly share code, notes, and snippets.

View ashwoods's full-sized avatar

Ashley Camba ashwoods

View GitHub Profile
@ashwoods
ashwoods / gist:4524517
Created January 13, 2013 15:08
combining resumable.js with md5spark
<html>
<head>
<title>HTML5 File example</title>
<STYLE TYPE="text/css">
<!--
TD{font-family: Arial, Helvetica, sans-serif; font-size: 8pt;}
--->
</STYLE>
<style>.example{padding:10px;border:1px solid #ccc}#drop_zone{border:2px dashed #bbb;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;padding:25px;text-align:center;font:20pt bold,"Vollkorn";color:#bbb}.thumb{height:75px;border:1px solid #000;margin:10px 5px 0 0}#progress_bar{margin:10px 0;padding:3px;border:1px solid #000;font-size:14px;clear:both;opacity:0;-o-transition:opacity 1s linear;-moz-transition:opacity 1s linear;-webkit-transition:opacity 1s linear;-ms-transition:opacity 1s linear}#progress_bar.loading{opacity:1}#progress_bar .percent{background-color:#9cf;height:auto;width:0}#byte_content{margin:5px 0;max-height:100px;overflow-y:auto;overflow-x:hidden}#byte_range{margin-top:5px}</style>
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <[email protected]>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
@ashwoods
ashwoods / gist:6883938
Created October 8, 2013 12:29
tirolissimo export
for entry in award_entries:
try:
extra_data = entry.entrydata_set.get(slug='step1')
kunde = extra_data.answer.get('kunde')
agentur = extra_data.answer.get('agentur')
except:
kunde = None
agentur = None
entry_row = [
@ashwoods
ashwoods / gist:6973308
Last active April 26, 2018 12:33
entry creation in transaction.
INSERT INTO "entries_entry" ("created",
"modified",
"award_id",
"category_id",
"user_id",
"status",
"status_changed",
"position",
"price",
"title")
##teamcity[testFailed message='Error' error='true' name='test_entry_code_award_counter' details='Traceback (most recent call last):|n File "/vagrant/submitz/apps/entries/tests.py", line 36, in test_entry_code_award_counter|n self.assertEqual(|'%s-%04d|' % (entry.category.code, i), entry.code)|n File "/vagrant/submitz/apps/entries/models.py", line 190, in code|n position = self.award_position|n File "/vagrant/submitz/apps/entries/models.py", line 212, in award_position|n row_number = raw[0|].row_number - 1|n File "/home/vagrant/.virtualenvs/submitz/local/lib/python2.7/site-packages/django/db/models/query.py", line 1617, in __getitem__|n return list(self)[k|]|n File "/home/vagrant/.virtualenvs/submitz/local/lib/python2.7/site-packages/django/db/models/query.py", line 1600, in __iter__|n instance = model_cls(**model_init_kwargs)|n File "/vagrant/submitz/apps/entries/models.py", line 85, in __init__|n self._status = self.status|n File "/home/vagrant/.virtualenvs/submitz/local/lib/python2.
##teamcity[testFailed message='Error' error='true' name='test_entry_code_award_counter' details='Traceback (most recent call last):|n File "/vagrant/submitz/apps/entries/tests.py", line 36, in test_entry_code_award_counter|n self.assertEqual(|'%s-%04d|' % (entry.category.code, i), entry.code)|n File "/vagrant/submitz/apps/entries/models.py", line 190, in code|n position = self.award_position|n File "/vagrant/submitz/apps/entries/models.py", line 212, in award_position|n row_number = raw[0|].row_number - 1|n File "/home/vagrant/.virtualenvs/submitz/local/lib/python2.7/site-packages/django/db/models/query.py", line 1617, in __getitem__|n return list(self)[k|]|n File "/home/vagrant/.virtualenvs/submitz/local/lib/python2.7/site-packages/django/db/models/query.py", line 1600, in __iter__|n instance = model_cls(**model_init_kwargs)|n File "/vagrant/submitz/apps/entries/models.py", line 85, in __init__|n self._status = self.status|n File "/home/vagrant/.virtualenvs/submitz/local/lib/python2.

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
sudo apt-get install ruby-dev
sudo gem install rdoc
sudo gem install guard
sudo gem install guard-livereload

Keybase proof

I hereby claim:

  • I am ashwoods on github.
  • I am ashwoods (https://keybase.io/ashwoods) on keybase.
  • I have a public key whose fingerprint is E4F4 E15C BB1E 0062 1F90 9F24 DE62 ADE2 A6C6 A243

To claim this, I am signing this object:

@ashwoods
ashwoods / cache.conf
Last active August 31, 2016 17:53
Example nginx configuration with SSL, uwsgi, Cache
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;