Skip to content

Instantly share code, notes, and snippets.

View jd's full-sized avatar
🦾

Julien Danjou jd

🦾
View GitHub Profile
@jd
jd / handson.py
Last active April 25, 2016 17:48
Hands-on Gnocchi + CK @ OpenStack Summit Newton
#!/usr/bin/env python
import uuid
import logging
import os
import random
import sys
from keystoneauth1.identity import v3
from keystoneauth1 import session
from keystoneclient.v3 import client as ks
# -*- 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 February 12, 2016 12:00
Count trailing and leading zeroes in Python
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 February 9, 2016 15:45
Carbonara compressiong using double delta + RLE on timestamps and LZ4
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 September 9, 2015 13:14
OpenStack meetup bio+pitch Gnocchi
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 August 19, 2014 14:48
Starring all OpenStack Git repositories
!/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()
@jd
jd / keybase.md
Created August 16, 2014 12:39
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 August 29, 2015 14:01
Gnocchi TODO list
  • 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>
@jd
jd / gist:9325172
Last active August 29, 2015 13:56
# 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)
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