Skip to content

Instantly share code, notes, and snippets.

View pauricthelodger's full-sized avatar

Padraic Harley pauricthelodger

View GitHub Profile
@fohlin
fohlin / forms.py
Created January 8, 2011 18:50
A version of Django's UserCreationForm that uses email instead of username, with some nifty features. (Maybe not super robust yet, in terms of concurrency...)
import re
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class UniqueUserEmailField(forms.EmailField):
"""
An EmailField which only is valid if no User has that email.
"""
def validate(self, value):
@dstufft
dstufft / fabfile.py
Created March 10, 2011 02:01
A fabfile for deploying a Django app with VirtualEnvWrapper, PIP and Supervisor
# Run this like fab -R www deploy
from fabric.api import *
REPO_URL = 'git@github.com:username/repo.git'
PROJECT_DIR = '$HOME/projects/projectname'
PROJECT_NAME = 'projectname'
SERVER_NAME = 'projectname.servername' # I use gunicorn, so i have projectname.gunicorn
env.roledefs['www'] = ['www1.example.com']
@comp615
comp615 / leaflet_numbered_markers.css
Created April 2, 2012 23:51
Numbered Markers in Leaflet (JS Mapping)
.leaflet-div-icon {
background: transparent;
border: none;
}
.leaflet-marker-icon .number{
position: relative;
top: -37px;
font-size: 12px;
width: 25px;
@niwinz
niwinz / output.txt
Created April 20, 2012 19:04
Mini SSH library for python3 based on subprocess
[niwi@vaio.niwi.be][~]% python3 subprocess_ssh.py
(0, b'Linux vaio.niwi.be 3.3.2-1-ARCH #1 SMP PREEMPT Sat Apr 14 09:48:37 CEST 2012 x86_64 Intel(R) Core(TM)2 Duo CPU T6600 @ 2.20GHz GenuineIntel GNU/Linux')
(0, b'processor\t: 0\nvendor_id\t: GenuineIntel\ncpu family\t: 6\nmodel\t\t: 23\nmodel name\t: Intel(R) Core(TM)2 Duo CPU T6600 @ 2.20GHz\nstepping\t: 10\nmicrocode\t: 0xa07\ncpu MHz\t\t: 2193.716\ncache size\t: 2048 KB\nphysical id\t: 0\nsiblings\t: 2\ncore id\t\t: 0\ncpu cores\t: 2\napicid\t\t: 0\ninitial apicid\t: 0\nfpu\t\t: yes\nfpu_exception\t: yes\ncpuid level\t: 13\nwp\t\t: yes\nflags\t\t: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dts\nbogomips\t: 4389.24\nclflush size\t: 64\ncache_alignment\t: 64\naddress sizes\t: 36 bits physical, 48 bits virtual\npower management:\n
@jacobvosmaer
jacobvosmaer / gist:3187346
Created July 27, 2012 10:35
Open all files with git merge conflicts in Vim

Open all files with git merge conflicts in MacVim

git diff --name-only | uniq | xargs mvim

When git encounters a merge conflict, e.g. during a rebase, it drops you back into the shell with a dirty working directory. I like this one-liner for opening all files with a merge conflict in MacVim.

Once you're in Vim, you can then switch between the files with :n and :prev, or another favourite: :w | n (save current file and open the next command line-supplied file).

UPDATE: see below for a version that works with real terminal commands.

@maciakl
maciakl / MC Cheat Sheet
Last active June 7, 2023 19:45
Midnight Commander Cheat Sheet
Shortcut Description
---------------------------------------------------------------
C-o Drop to the console
* Invert selection on files
A-s Incremental search
A-o Open selected directory in opposite panel
A-. Toggle "Show Hidden Files" feature
A-Enter Put name of the highlighted file on command line
@skyebook
skyebook / backup_postgres.sh
Last active April 16, 2016 13:20
Backup OpenShift PostgreSQL Database
#!/bin/bash
# Backs up the OpenShift PostgreSQL database for this application
# by Skye Book <skye.book@gmail.com>
NOW="$(date +"%Y-%m-%d")"
FILENAME="$OPENSHIFT_DATA_DIR/$OPENSHIFT_APP_NAME.$NOW.backup.sql.gz"
pg_dump $OPENSHIFT_APP_NAME | gzip > $FILENAME
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active June 10, 2024 15:37
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@coordt
coordt / testinstances.py
Last active December 24, 2015 22:49
This is a set of Fabric tasks to create and manage dynamic test instances on a server.
"""
Tasks for managing a test server
"""
import os
from fabric.api import cd, env, prefix, run, sudo, task
from fabric.contrib.files import exists, sed
from fabric.context_managers import hide
from fabric.colors import green, red
@chhantyal
chhantyal / useful_unix_commands.sh
Last active December 26, 2015 20:49
Some useful server commands - Linux, nginx, uwsgi or gunicorn, Postgres and supervisor
# Kernel version and system architecture
uname -a
# Name and version of distribution
head -n1 /etc/issue
# Partitions registered on the system
cat /proc/partitions
# Total RAM seen by the system
grep MemTotal /proc/meminfo