Skip to content

Instantly share code, notes, and snippets.

View federicobond's full-sized avatar

Federico Bond federicobond

View GitHub Profile
@federicobond
federicobond / django_extras_instrumentor.py
Last active May 7, 2024 09:10
OpenTelemetry Instrumentor for tracing Django management command calls
from functools import wraps
from django.core.management.base import BaseCommand
from opentelemetry import trace
from opentelemetry.instrumentation.django_extras.package import _instruments
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
_COMMAND_TRACE_PREFIX = "command/"
_DJANGO_COMMAND_KEY = "django.command"
@federicobond
federicobond / jwt_test.go
Created May 20, 2019 20:05
Sign and verify JWT with Go
package main
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"fmt"
"testing"
jwt "github.com/dgrijalva/jwt-go"
@federicobond
federicobond / bitforge.md
Created March 21, 2016 14:34
Bitforge library architecture

The other day we had an in-person meeting with @slezica, @yemel, @esneider et al., and we talked about the library architecture. This is what came out of it:

We decided early on that Bitforge should provide accurate representations of protocol objects. These are Transactions, Inputs, Outputs, Addresses, etc. They are immutable and syntactically valid since creation. We cannot check network consensus rules like double spends (for obvious reasons) and script semantics, like valid signatures (which would require us to execute the script, a computationally expensive operation) but, other than that, these objects can be considered well formed and valid.

Bitforge therefore needs a way to model some objects that are in the process of becoming proper protocol objects. The most obvious case of these are unsigned transactions. These objects can (and will) have friendlier interfaces. While the Transaction constructor receives signed inputs and an output list, the object that represents an unsigned transaction Transac

@federicobond
federicobond / README.md
Created December 31, 2015 06:47 — forked from mbostock/.block
Choropleth

This choropleth encodes unemployment rates from 2008 with a quantize scale ranging from 0 to 15%. A threshold scale is a useful alternative for coloring arbitrary ranges.

@federicobond
federicobond / fix-makemessages.sh
Last active February 4, 2024 12:43
Fix errors / warnings when running `python manage.py makemessages` with `xlwt` installed.
#!/bin/bash
#
# This scripts solves the following error when running Django's makemessages with xlwt installed.
# It also gets rid of the warnings.
#
# CommandError: errors happened while running xgettext on UnicodeUtils.py
# xgettext: ./env/lib/python2.7/site-packages/xlwt/UnicodeUtils.py:1: Unknown encoding "windows-1252". Proceeding with ASCII instead.
# xgettext: Non-ASCII string at ./env/lib/python2.7/site-packages/xlwt/UnicodeUtils.py:37.
# Please specify the source encoding through --from-code or through a comment
#  as specified in http://www.python.org/peps/pep-0263.html.
Verifying I am +federicobond on my passcard. https://onename.com/federicobond
@federicobond
federicobond / missing.sh
Last active August 29, 2015 14:04
Small script to find missing translation strings in Processing
#!/bin/bash
# Small script to find missing translation strings in Processing
#
# Use with no arguments to find strings that are in the codebase but have not
# been added to the default language file.
#
# Use with a language code as first argument to find strings that are in the
# default properties file but have not yet been translated to the given
# language.

Keybase proof

I hereby claim:

  • I am federicobond on github.
  • I am federicobond (https://keybase.io/federicobond) on keybase.
  • I have a public key whose fingerprint is 45ED 2027 0053 0F06 D919 9F9F 3C44 A4B4 EB48 DE76

To claim this, I am signing this object:

@federicobond
federicobond / messages.js
Last active December 19, 2015 03:19
Client-side messages for Bootstrap
// messages.js - Client-side messages for Bootstrap
// (c) 2013 Federico Bond
// messages.js may be freely distributed under the MIT License.
!function ($) {
"use strict";
var templateString = '<div class="alert alert-{{ cls }}">{{ msg }}' +
'<a class="close" data-dismiss="alert" href="#">&times;</a>' +
@federicobond
federicobond / letterpress.py
Last active October 13, 2015 13:48
Small script to give you the longest words you can play in Letterpress for iOS. Used it for demonstration purposes. Cheating spoils the fun.
from collections import Counter
class Letterpress(object):
DICTIONARY = "Words/Words/en.txt"
def __init__(self, available):
"""Inialize letterpress object"""
self.words = self.build_words()