Skip to content

Instantly share code, notes, and snippets.

View SebCorbin's full-sized avatar

Sébastien Corbin SebCorbin

View GitHub Profile
@JordanReiter
JordanReiter / management_email_admins.py
Created March 28, 2017 21:08
Use the EmailAdminsOnErrorCommand class instead of BaseCommand so that your Django management commands send error emails to admins
# This file provides a base Command class that handles sending errors via mail_admins
# Make sure to adjust the LOGGING variable in settings
# Credit to Abdulla Diab: https://mpcabd.xyz/make-django-management-commands-send-errors-email-admins/
import sys
import logging
from django.core.management import BaseCommand
logger = logging.getLogger('management.command')
@olih
olih / jq-cheetsheet.md
Last active May 2, 2024 00:42
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@danni
danni / fields.py
Created March 8, 2016 08:52
Multi Choice Django Array Field
from django import forms
from django.contrib.postgres.fields import ArrayField
class ChoiceArrayField(ArrayField):
"""
A field that allows us to store an array of choices.
Uses Django 1.9's postgres ArrayField
and a MultipleChoiceField for its formfield.
@pounard
pounard / moche.js
Last active August 29, 2015 14:12
/*jslint browser: true, plusplus: true, indent: 2 */
/*global Node, console, Blob */
/**
* Et tu pleures. Et tu pleures. Et tu pleures. Mais ça marche.
*
* But how the fuck will I make this work?
* - Step 1: Open your firebug (or other) console
* - Step 2: Paste this code into it
* - Step 3: Click "Execute" (or maybe "Run")
* - Step 4: If everything went OK your browser will download the file
@regilero
regilero / serialization_sql_dump_cleaner.sh
Last active September 1, 2016 13:01
DNS replacement script in SQL dumps containing (also) PHP serialized strings.This script use bash and perl' perl is used to increment serialized string length while performing DNS replacement It also use sed for other basic DNS replacements
#!/bin/bash
##################################################################
# Licensed under GNU GPL v3 #
# regis.leroy@gmail.com #
# #
# DNS replacement scrpit in SQL dumps containing (also) PHP #
# serialized strings. #
# This script use bash and perl' perl is used to increment #
# serialized string length while performing DNS replacement #
# It also use sed for other basic DNS replacements #
@codemasher
codemasher / gw2_objectives.json
Last active December 17, 2015 14:19
GW2 WvW Objectives with translations de/es/fr and coordinates for use with the GW2 maps API
{"1":{"score":25,"coords":[10766,13656],"type":"keep","name":{"de":"Aussichtspunkt","en":"Overlook","es":"Mirador","fr":"Belvédère"}},
"2":{"score":25,"coords":[11497,15121],"type":"keep","name":{"de":"Tal","en":"Valley","es":"Valle","fr":"Vallée"}},
"3":{"score":25,"coords":[9606,15132],"type":"keep","name":{"de":"Tiefland","en":"Lowlands","es":"Vega","fr":"Basses terres"}},
"4":{"score":5,"coords":[10211,15437],"type":"camp","name":{"de":"Golanta-Lichtung","en":"Golanta Clearing","es":"Claro Golanta","fr":"Clairière de Golanta"}},
"5":{"score":5,"coords":[11226,13754],"type":"camp","name":{"de":"Pangloss-Anhöhe","en":"Pangloss Rise","es":"Colina Pangloss","fr":"Montée de Pangloss"}},
"6":{"score":5,"coords":[9850,13561],"type":"camp","name":{"de":"Speldan Kahlschlag","en":"Speldan Clearcut","es":"Claro Espeldia","fr":"Forêt rasée de Speldan"}},
"7":{"score":5,"coords":[11030,15559],"type":"camp","name":{"de":"Danelon-Passage","en":"Danelon Passage","es":"Pasaje Danelon","fr":"Passage Danelon"}},
"8":{"score
@opi
opi / gist:3736544
Created September 17, 2012 10:08
Git branch in terminal
#goz git bash
c_cyan=`tput setaf 6`
c_blue=`tput setaf 4`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()