This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Helper(object): | |
res = None | |
def search(self): | |
d = this_returns_a_deferred() | |
def _save(results): | |
self.res = results | |
d.addCallback(_save) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'form.html' %} | |
{% block form_body %} | |
{% for fieldset in form.fieldsets %} | |
<fieldset class="{{ fieldset.classes }}"> | |
{% if fieldset.legend %} | |
<legend>{{ fieldset.legend }}</legend> | |
{% endif %} | |
{% if fieldset.description %} | |
<p class="form-field-description">{{ fieldset.description }}</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# Quick and dirty check for BlackHole RAT (OSX/MusMinim-A) | |
# * http://www.sophos.com/security/analyses/viruses-and-spyware/osxmusminima.html | |
# | |
# USAGE: | |
# - Copy this file in your Desktop | |
# - Open Terminal.app | |
# - Run the following commands: | |
# - cd ~/Desktop | |
# - chmod +x blackholeratcheck.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location /admin/ { | |
if ( $scheme == http ) { | |
rewrite ^ https://$host$uri permanent; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#nginx.conf | |
user www-data; | |
worker_processes 1; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
use epoll; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sqlite> .schema people_person | |
CREATE TABLE "people_person" ("picture" varchar(200), "first_name" varchar(64), "last_name" varchar(64), "description" text, "web_page" varchar(200), "visitor" bool NOT NULL DEFAULT False, "e_mail" varchar(75), "rank_id" integer, "current" bool, "public" bool, "mid_name" varchar(64), "id" integer PRIMARY KEY); | |
sqlite> select 'production',visitor from people_person; | |
production|False | |
production|False | |
production|False | |
production|False | |
production|False | |
production|False | |
production|False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE "people_person" ("picture" varchar(200), "first_name" varchar(64), "last_name" varchar(64), "description" text, "web_page" varchar(200), "visitor" bool NOT NULL DEFAULT False, "e_mail" varchar(75), "rank_id" integer, "current" bool, "public" bool, "mid_name" varchar(64), "id" integer PRIMARY KEY); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> Person.objects.filter(visitor=False) | |
[] | |
>>> Person.objects.values('visitor') | |
[{'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, {'visitor': False}, '...(remaining elements truncated)...'] | |
>>> Person.objects.all().filter(visitor=False) | |
[] | |
>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def forwards(self, orm): | |
"Write your forwards methods here." | |
def set_real_type(obj): | |
obj.real_type = orm["contenttypes.ContentType"].objects.get_for_model(type(obj)) | |
obj.save() | |
# migrate existing objects | |
for obj in orm.Book.objects.all(): | |
set_real_type(obj) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
import datetime | |
from south.db import db | |
from south.v2 import DataMigration | |
from django.db import models | |
from django.utils.encoding import smart_unicode | |
class Migration(DataMigration): | |
def forwards(self, orm): |