Skip to content

Instantly share code, notes, and snippets.

@jixiaolong
jixiaolong / django_service.py
Created October 16, 2017 02:38 — forked from mikofski/django_service.py
Start a Windows service to run the Django debug server - WARNING! not recommended for deployment!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Attribution: Hijacked from tracservice.py by Florent Xicluna <laxyf@yahoo.fr>
# http://trac-hacks.org/wiki/WindowsServiceScript
#
# To use this class, users must do the following:
# 1. Download and install the PyWin32all package
# (http://starship.python.net/crew/mhammond/win32/)
# 2. Edit the constants section with the proper information.
import signal
class TimeoutError(Exception):
pass
class Timeout(object):
def __init__(self, seconds):
self.seconds = seconds
@jixiaolong
jixiaolong / gist:ab1d3a3403c91b89c9472525e019e489
Created May 26, 2016 07:21
django 中使用postgres报duplicate key value violates unique constraint error
question:
-----------------
IntegrityError: duplicate key value violates unique constraint "eshop_screeninformation_pkey"
DETAIL: Key (id)=(1) already exists.
------------------
answer:
SELECT setval('tablename_id_seq', (SELECT MAX(id) FROM tablename)+1);
@jixiaolong
jixiaolong / supervisord-example.conf
Created May 16, 2016 03:10 — forked from didip/supervisord-example.conf
Example configuration file for supervisord.conf
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=error ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon
#################################
#
# 本清单基于 ubuntu 12.04,
# 下个 ubuntu 的 LTS
# 发出来后,会相应更新这里的内容。我的目标是按步执行可以零错误完成安装。
# 注意,本文件只是一个清单,不是一个可以安全执行的脚本
#
#################################
# create a linode,login as root, and create a common user for all the tasks