Skip to content

Instantly share code, notes, and snippets.

mike@rbci:~$ psql -U postgres
psql (9.0.3)
Type "help" for help.
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0';
UPDATE 1
postgres=# \c template0
You are now connected to database "template0".
template0=# update pg_database set datistemplate = FALSE where datname = 'template1';
UPDATE 1
@KristianOellegaard
KristianOellegaard / Makefile
Created March 26, 2013 14:40
Makefile for creating releases and publishing them on a private Gemfury PyPi
PROJECT = "<your project>"
current-version:
@echo "Current version is `cat ${PROJECT}/__init__.py | awk -F '("|")' '{ print($$2)}'`"
build:
git stash
python setup.py sdist
- git stash pop
@jcjones
jcjones / letsencrypt-renew.sh
Last active October 11, 2016 16:29
Cron script to renew Let's Encrypt certs using the official client
#!/bin/bash
# This is free and unencumbered software released into the public domain.
#
# This script is designed to be run daily by cron. Please run it with randomness in its timing to
# avoid load spikes at Let's Encrypt. One example, running between midnight at 2 AM, would be:
#
# 0 0 * * * sleep $[(RANDOM % 115)+5]m ; /usr/sbin/letsencrypt-renew.sh
#
# If you aren't using Nginx, adjust the startServer and stopServer methods to suit. Also, you could
# use the webroot method.
@miraculixx
miraculixx / fieldselect.py
Last active June 7, 2017 15:36
select tastypie fields returned by the api
class FieldSelectionMixin(object):
"""
add ability to Resource to query specific fields. This works by
removing any fields not in the fields list provided by the fields
query parameter.
Programming Use:
class MyResource(FieldSelectionMixin, ModelResource):
...
(as with any normal resource)
@burlresearch
burlresearch / .muttrc
Created November 19, 2014 13:48
Mutt IMAP setup for Google Apps account
set realname = "Scott Burlington"
set from = "scott@burlresearch.com"
set imap_user = "scott@burlresearch.com"
set imap_pass = "XXX"
set smtp_url = "smtp://scott@burlresearch.com@smtp.gmail.com:587/"
set smtp_pass = "XXX"
set folder = imaps://imap.gmail.com/
set spoolfile = "+INBOX"
set postponed = "+[Gmail]/Drafts"
@grantmcconnaughey
grantmcconnaughey / pdf.py
Last active February 8, 2021 21:50 — forked from zyegfryed/pdf.py
Outputting PDFs with Django 1.8 and FDFgen
# -*- coding: utf-8 -*-
import codecs
import subprocess
from fdfgen import forge_fdf
from django.core.exceptions import ImproperlyConfigured
from django.template import engines
from django.template.backends.base import BaseEngine
from django.template.engine import Engine, _dirs_undefined
@philfreo
philfreo / bucket_policy.js
Created October 6, 2012 01:27
AWS S3 bucket policy to make all files public (+CORS)
{
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucket_name_here/*"
@asfaltboy
asfaltboy / conftest.py
Last active March 30, 2022 23:52
A pytest fixture to test Django data migrations
# based on https://gist.github.com/blueyed/4fb0a807104551f103e6
# and on https://gist.github.com/TauPan/aec52e398d7288cb5a62895916182a9f (gistspection!)
from django.core.management import call_command
from django.db import connection
from django.db.migrations.executor import MigrationExecutor
import pytest
@danishabdullah
danishabdullah / Postgres kill all idle in transaction.md
Last active February 27, 2024 19:55
Postgres kill all idle in transaction

given a database named db:

SELECT pg_terminate_backend(pid) 
FROM pg_stat_activity 
WHERE datname='db'
  AND state = 'idle in transaction'
@max-mapper
max-mapper / bibtex.png
Last active March 10, 2024 21:53
How to make a scientific looking PDF from markdown (with bibliography)
bibtex.png