Skip to content

Instantly share code, notes, and snippets.

View jd's full-sized avatar
🦾

Julien Danjou jd

🦾
View GitHub Profile
@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 / 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 / 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
@jd
jd / gist:6c53a9877cad50352fff31aecbd29410
Last active June 10, 2016 10:28
Gnocchi + Aodh alarm triggering test
➔ gnocchi metric create -a high
+------------------------------------+-------------------------------------------------------------------+
| Field | Value |
+------------------------------------+-------------------------------------------------------------------+
| archive_policy/aggregation_methods | std, count, 95pct, min, max, sum, median, mean |
| archive_policy/back_window | 0 |
| archive_policy/definition | - points: 3600, granularity: 0:00:01, timespan: 1:00:00 |
| | - points: 10080, granularity: 0:01:00, timespan: 7 days, 0:00:00 |
| | - points: 8760, granularity: 1:00:00, timespan: 365 days, 0:00:00 |
| archive_policy/name | high |
import cradox as rados
POOL_NAME = "gnocchi-test"
CONFFILE = ""
USERNAME = ""
OBJECT_NAME = "myomapobject"
ITER = 100
# options['keyring'] = conf.ceph_keyring
# options['key'] = conf.ceph_secret
@jd
jd / emacs-revert-9344612d3cd164317170b6189ec43175757e4231.diff
Last active June 20, 2017 09:20
Revert commit 9344612d3cd164317170b6189ec43175757e4231 of Emacs
--- emacs/src/macfont.m.orig 2017-06-20 11:18:58.000000000 +0200
+++ emacs/src/macfont.m 2017-06-20 11:19:26.000000000 +0200
@@ -2373,9 +2373,9 @@
!= (spacing >= FONT_SPACING_MONO)))
continue;
- /* Don't use a color bitmap font until it is supported on
- free platforms. */
- if (sym_traits & kCTFontTraitColorGlyphs)
+ /* Don't use a color bitmap font unless its family is
@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 / gnocchi-metric-delete.py
Last active July 21, 2017 16:12
Deleting Gnocchi metric with Keystone auth
#!/usr/bin/env python
import os
from concurrent.futures import thread
from gnocchiclient import client
from keystoneauth1 import identity
from keystoneauth1 import session
auth = identity.Password(auth_url=os.getenv("OS_AUTH_URL"),
@jd
jd / micro-metricd.py
Created February 8, 2018 15:40
Gnocchi profiling tool
# -*- encoding: utf-8 -*-
import cProfile
import random
import uuid
import daiquiri
import numpy
from gnocchi.cli import metricd
from gnocchi import incoming
@jd
jd / filter.py
Created April 24, 2018 11:56
Filter with an AST
import operator
class InvalidFilter(Exception):
pass
class Filter(object):
binary_operators = {
u"=": operator.eq,