Skip to content

Instantly share code, notes, and snippets.

View vberlier's full-sized avatar

Valentin Berlier vberlier

  • Paris, France
View GitHub Profile
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@jordanpoulton
jordanpoulton / pair_programming_roles
Last active September 16, 2024 19:06
Pair Programming Role Definitions - Driver:Navigator
Driver:
-Write the code according to the navigator's specification
-Listen intently to the navigators instructions
-Ask questions wherever there is a lack of clarity
-Offer alternative solutions if you disagree with the navigator
-Where there is disagreement, defer to the navigator. If their idea fails, get to failure quickly and move on
-Make sure code is clean
-Own the computer / keyboard
-Ignore larger issues and focus on the task at hand
-Trust the navigator - ultimately the navigator has the final say in what is written
@Artazor
Artazor / await-promises.md
Last active July 25, 2023 11:44
Await operator desugaring into promises

Here is an example how await operator can be desugared into Promise-based code without ES6 generators (and state machines that emulate generators missing in ES5). The only assumption is that there is Promise.resolve (to create an empty promise for the loop finalization) among the globals.

Examples are written with "throw early" policy adoption: if promisified code has a synchronous preamble that throws we prefer to throw instead of creating rejected Promise.

Note that patterns below don't cover control flow breaks like return, break, continue and throw (for these breaks we should use a bit more complex structures).

Asynchronous sequence

@ekinertac
ekinertac / field_blank_null.md
Last active May 28, 2024 05:50
Django null/blank field explanation
Fields null=True blank=True
CharField, TextField, SlugField, EmailField, CommaSeparatedIntegerField DON'T Django's convention is to store empty values as the empty string, and to always retrieve NULL or empty values as the empty string for consistency. OK Do this if you want the corresponding form widget to accept empty values. If you set this, empty values get stored as empty strings in the database.
BooleanField DON'T Use NullBooleanField instead. DON'T
IntegerField, FloatField, DecimalField OK If you wabt to be able to set the value to NULL in the database OK if you want the corresponding form widget to accept empty values. if so out will also want to set null=True
DateTimeField, DateField, TimeField OK if you want to be able to set the value to NULL in the database. OK If you want the corresponding form widget to accept empty values, or if you are using auto now or auto now add. If so, you will al
@bjinwright
bjinwright / custom_storages.py
Created December 7, 2016 22:50
Custon S3 Django-Storages backend made for use with CloudFront with multiple origins
from django.conf import settings
from django.utils.encoding import filepath_to_uri
from storages.backends.s3boto import S3BotoStorage
class StaticStorage(S3BotoStorage):
location = settings.STATICFILES_LOCATION
def url(self, name, headers=None, response_headers=None, expire=None):
return '{}{}'.format(settings.STATIC_URL,filepath_to_uri(name))
@Podshot
Podshot / chunk_reader.py
Last active September 20, 2023 21:04
Proof of Concept for converting BlockState Long IDs to Palette indices. Critical for loading 1.13 Minecraft Java Edition worlds. Run with the command: "python proof_of_concept.py" to use. If you use any snippet of code from this, please give appropriate credit to the respective authors.
"""
Standalone chunk loader/reader from pymclevel with all the fancy repair/OOP stuff removed
"""
from __future__ import unicode_literals, print_function
import os
try:
from pymclevel import nbt
except ImportError:
import nbt
import struct
@Fumesover
Fumesover / List.md
Last active February 18, 2019 00:08
Fiches destinations S4
@dutc
dutc / defaults.py
Created June 14, 2018 21:36
PEP 563 -- Postponed Evaluation of Annotations (https://www.python.org/dev/peps/pep-0563/)
from __future__ import annotations
from inspect import signature
from functools import wraps
from collections import namedtuple
opt = namedtuple('Optional', '')()
def better_defaults(f):
sig = signature(f)
@wraps(f)
def func(*args, **kwargs):
@dgilge
dgilge / 01_complete_authentication_as_api.md
Created June 15, 2018 11:15
How to implement all needed auth endpoints including login with OAuth2 for a SPA using Django REST framework, django-rest-auth and django-allauth

Complete authentication as API including OAuth2 endpoints

I implemented an auth API for a SPA. This is rarely documented and therefore I want to share here how I did it hoping it will be a help for others.

We are still working on it and I'll update this document accordingly.

This tutorial uses following versions:

Package Version
@Bentroen
Bentroen / pca_model_deanimator.py
Last active August 9, 2018 07:23
#PokeCA Model De-animator | Extract frames from animated Pokémon
########################################################################################
# #PokeCA Model De-animator by Bentroen #
########################################################################################
# #
# Usage instrucions: point 'input_path' to a folder containing the 'models' and #
# 'textures' folders from the original map's resource pack. The script will #
# fetch the correct model according to 'model_list', and export the following #
# to 'output_path': every frame to 'models/all_frames/', every first frame to #
# 'models/' and first frame of textures to 'textures/'. If the texture itself #
# is animated (changes from frame to frame, e.g. Ternion's blue fire), only #