Skip to content

Instantly share code, notes, and snippets.

Brice Fernandes bricef

Block or report user

Report or block bricef

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bricef
bricef / trace_calls.py
Created Jan 18, 2020
Call tracing decorator
View trace_calls.py
class TraceCalls(object):
""" Use as a decorator on functions that should be traced. Several
functions can be decorated - they will all be indented according
to their call depth.
source: https://eli.thegreenplace.net/2012/08/22/easy-tracing-of-nested-function-calls-in-python
"""
def __init__(self, stream=sys.stdout, indent_step=2, show_ret=False):
self.stream = stream
self.indent_step = indent_step
self.show_ret = show_ret
@bricef
bricef / tmp_file_value_context.py
Created Jan 18, 2020
Given a value, create a temporary file and make this file available for the duration of the context.
View tmp_file_value_context.py
class ValueContext(object):
"""
A ValueContext is constructed from a value that can be writtent to a file
and then exposes the value as a temporary file in its context.
The temporary file path can be accessed using its `name` attribute.
For example:
@bricef
bricef / merge_mappings.py
Last active Dec 13, 2019 — forked from angstwad/dict_merge.py
Recursive dictionary merge in Python
View merge_mappings.py
# Recursive dictionary merge
# Copyright (C) 2019 Brice Fernandes <brice.fernandes@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
View better_ps1.sh
B_BLACK="\[\e[40m\]"
B_RED="\[\e[41m\]"
B_GREEN="\[\e[42m\]"
B_YELLOW="\[\e[43m\]"
B_BLUE="\[\e[44m\]"
B_MAGENTA="\[\e[45m\]"
B_CYAN="\[\e[46m\]"
B_WHITE="\[\e[47m\]"
F_BLACK="\[\e[30m\]"
View movie-titles.txt
1 - ???
2 - The Matrix
3 - Speed
4 - Leaving Las Vegas
5 - Lalaland
6 - 12 monkeys
7 - π
8 - Dr No
9 - Seven
10 - Home Alone
@bricef
bricef / docker-compose output
Last active Feb 19, 2018
Error on following readme instructions
View docker-compose output
➤ docker-compose -f services/dev.yml up --build
Starting services_api_1 ... done
Starting services_web_1 ... done
Attaching to services_api_1, services_web_1
api_1 |
api_1 | > json-server@ prestart /home
api_1 | > npm install
api_1 |
web_1 |
web_1 | > react-slingshot@7.0.0 prestart /home
@bricef
bricef / party.dot
Last active Feb 13, 2018
Abduction: Bat out of hell party - attitude graph
View party.dot
//➤ neato party.dot -Gsep="+200" -Goverlap=scalexy -Tpng -o party.png && open party.png
digraph party {
Ad [label="Adric"];
Az [label="Azrael"];
P [label="Peridot"];
Li [label="Liberace"];
Pe [label="Pete"];
K [label="Koros"];
Lu [label="Luth"];
F [label="Fletcher"];
View index.html
<html>
<body>bucket served file ok</body>
</html>
@bricef
bricef / Hash.cs
Last active Oct 3, 2016
Salting and Hashing passwords correctly in .NET
View Hash.cs
/**
* From http://lockmedown.com/hash-right-implementing-pbkdf2-net/
*/
public class Hash
{
private const int SaltByteLength = 32;
private const int DerivedKeyLength = 32;
private const int IterationCount = 48000;
private const char separator = '|';
@bricef
bricef / PaddingOracle.py
Created Sep 8, 2016
Padding Oracle attack example in python
View PaddingOracle.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
import sys
from Crypto.Cipher import AES
BLOCK_SIZE = 16 # bytes
INIT_VEC = 'This is an IV456' # hardcoding this is a terrible idea
You can’t perform that action at this time.