Skip to content

Instantly share code, notes, and snippets.

Julien Danjou jd

View GitHub Profile
View gorilla-xor-encoding.py
# -*- encoding: utf-8 -*-
#
# Copyright © 2016 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@jd
jd / count_lead_trail_zeroes.py
Last active Feb 12, 2016
Count trailing and leading zeroes in Python
View count_lead_trail_zeroes.py
def count_lead_and_trail_zeroes(d):
"""Count the number of leading and trailing zeroes in an integer."""
b = "{:064b}".format(d)
try:
return as_str.index("1"), 63 - as_str.rindex("1")
except ValueError:
return 64, 64
def count_lead_and_trail_zeroes(d):
# https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightLinear
@jd
jd / bench.py
Last active Feb 9, 2016
Carbonara compressiong using double delta + RLE on timestamps and LZ4
View bench.py
import math
import time
import random
import pandas
import datetime
from gnocchi import carbonara
points = 14400
sampling = 5
compress_times = 10
@jd
jd / gist:2169407c179341b6e2e0
Created Sep 9, 2015
OpenStack meetup bio+pitch Gnocchi
View gist:2169407c179341b6e2e0
Bio:
Julien est un développeur OpenStack depuis 4 ans, et des principaux développeurs de Ceilometer
depuis son incubation au sein d'OpenStack. Il travaille comme Principal Software Engineer chez Red Hat.
Pitch:
L'année dernière, un nouveau projet à fait son apparition au sein de Ceilometer: Gnocchi.
Il répond à la problématique de stockage des métriques à grande échelle, problème rencontré
par Ceilometer depuis sa création. Pour se faire, il fournit une API REST d'indexation de
resources et de stockage de séries temporelles.
Durant cette présentation, je vous présenterais les raisons de créations de ce projet,
@jd
jd / auto-star-openstack-repo
Created Aug 19, 2014
Starring all OpenStack Git repositories
View auto-star-openstack-repo
!/usr/bin/env python
from github import Github
USERNAME = "myusername"
PASSWORD = "mypassword"
USERS = ("openstack", "stackforge", "openstack-dev", "openstack-infra")
g = Github(USERNAME, PASSWORD)
me = g.get_user()
View keybase.md

Keybase proof

I hereby claim:

  • I am jd on github.
  • I am jdanjou (https://keybase.io/jdanjou) on keybase.
  • I have a public key whose fingerprint is 5361 BD40 015B 7438 2739 101A 611B A950 8B78 A5C2

To claim this, I am signing this object:

@jd
jd / gist:229ab8211aa9a6b547de
Last active Aug 29, 2015
Gnocchi TODO list
View gist:229ab8211aa9a6b547de
  • Allow PATCH on resources (for example changing "host" or "flavor_id" after a resize)
  • Allow to retrieve the list of resources for a user: /v1/resources/?user_id=<foo> -> return all instances too /v1/instances/?user_id=<foo>
  • Allow to retrieve the list of resources for a user with details: /v1/resources/?user_id=<foo>&detail=true -> return all instances too with full details (more costs as we need to look in other tables)
  • Allow to retrieve the list of resources with timestamp /v1/resources/?started_after=<timestamp>&ended_before=<timestamp>
View gist:9325172
# Current
__TOOZ_GROUP_LIST = [ group list ]
_TOOZ_GROUP_<foo> = { "member": { "last_seen": <time>, "capabilities": "foobar" } }
create_group => WRITE,(READ,WRITE,RETRY) => O(1)
get_groups => READ => O(1)
join_group => (READ,WRITE,RETRY) => O(1)
leave_group => (READ,WRITE,RETRY) => O(1)
get_members => READ => O(1)
View gist:8697880
Python 2.7.6 (default, Dec 9 2013, 18:09:21)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import base64
>>> base64.b64decode('lol')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/base64.py", line 76, in b64decode
raise TypeError(msg)
TypeError: Incorrect padding
View gist:8666438
def create_engine(sql_connection, sqlite_fk=False,
mysql_traditional_mode=False):
return session.create_engine(sql_connection,
sqlite_fk,
mysql_traditional_mode,
idle_timeout=CONF.database.idle_timeout,
connection_debug=CONF.databse.connection_debug,
max_pool_size=CONF.database.max_pool_size,
max_overflow=CONF.database.max_overflow,
pool_timeout=CONF.database.pool_timeout,
You can’t perform that action at this time.