Skip to content

Instantly share code, notes, and snippets.

View wo0dyn's full-sized avatar

Nicolas C. Dubois wo0dyn

View GitHub Profile
#!/bin/bash
usage() {
cat <<EOF
usage: git gone [-pldD] [<branch>=origin]
OPTIONS
-p prune remote branch
-n dry run: list the gone branches
-d delete the gone branches
-D delete the gone branches forcefully

Math Puzzle

One possible solution: brute force

import collections
import itertools
@nlhkabu
nlhkabu / cheatsheet.md
Last active April 8, 2019 23:31
Nicole's PeopleAsk Env CheatSheet

LXC

List all containers:

sudo lxc-ls -f

Stop peopleask container:

sudo lxc-stop -n peopleask

@twidi
twidi / drf_utils.py
Created December 21, 2016 14:34
Make Django Rest Framework correctly handle Django ValidationError raised in the save method of a model
"""
Sometimes in your Django model you want to raise a ``ValidationError`` in the ``save`` method, for
some reason.
This exception is not managed by Django Rest Framework because it occurs after its validation
process. So at the end, you'll have a 500.
Correcting this is as simple as overriding the exception handler, by converting the Django
``ValidationError`` to a DRF one.
"""
from django.core.exceptions import ValidationError as DjangoValidationError
@alopresto
alopresto / gpg_git_signing.md
Last active September 10, 2024 17:07
Steps to enable GPG signing of git commits.

If anyone is interested in setting up their system to automatically (or manually) sign their git commits with their GPG key, here are the steps:

  1. Generate and add your key to GitHub
  2. $ git config --global commit.gpgsign true ([OPTIONAL] every commit will now be signed)
  3. $ git config --global user.signingkey ABCDEF01 (where ABCDEF01 is the fingerprint of the key to use)
  4. $ git config --global alias.logs "log --show-signature" (now available as $ git logs)
  5. $ git config --global alias.cis "commit -S" (optional if global signing is false)
  6. $ echo "Some content" >> example.txt
  7. $ git add example.txt
  8. $ git cis -m "This commit is signed by a GPG key." (regular commit will work if global signing is enabled)
@kennethreitz
kennethreitz / check.sh
Created February 7, 2016 15:48
How to find out why your RST isn't rendering on PyPi
pip install readme-renderer && python setup.py check -rs
@bersace
bersace / etc dnsmasq.d custom
Last active March 13, 2017 11:32
Utiliser dnsmasq comme aiguilleur
# note que ça peut être /etc/NetworkManager/dnsmasq.d/custom pour utiliser NetworkManager comme aiguilleur.
bind-interfaces
except-interface=docker0
except-interface=virbr*
except-interface=lxcbr*
log-queries
dns-forward-max=5
# 1h de TTL de base
@carljm
carljm / jinja2backend.py
Created June 14, 2015 21:21
Django Jinja2 backend subclass with context processor support
class Jinja2Backend(jinja2backend.Jinja2):
def __init__(self, params):
self.context_processors = [
import_string(p)
for p in params['OPTIONS'].pop('context_processors', [])
]
super(Jinja2Backend, self).__init__(params)
# Luxafor via Python
# Dave Irvine www.daveirvine.me @dave_irvine
# Get PyUSB from:
# http://walac.github.io/pyusb/
#!/usr/bin/python
import usb.core
import usb.util
@wo0dyn
wo0dyn / maths-puzzle.md
Last active December 4, 2015 08:25
Can you do the maths puzzle for Vietnamese eight-year-olds that has stumped parents and teachers?

Can you do the maths puzzle for Vietnamese eight-year-olds that has stumped parents and teachers?

Source: article from The Guardian

Script

from itertools import permutations