Skip to content

Instantly share code, notes, and snippets.

View jd's full-sized avatar
🦾

Julien Danjou jd

🦾
View GitHub Profile
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 / 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 |
@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 / 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
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,
@jd
jd / gist:6210206
Last active December 20, 2015 23:09
=> GET /v2/meter/instances/statistics?reset_on=metadata.vm_state
<= {
'off': [ { avg: ... max: ... start: '2013-07-01 00:00:00', end: '2013-07-01 00:59:59' },
{ avg: ... max: ... start: '2013-07-01 03:00:00', end: '2013-07-01 03:59:59' },
'on': [ { avg: ... max: ... start: '2013-07-01 01:00:00', end: '2013-07-01 01:59:59' } ],
'suspended': [ { avg: ... max: ... start: '2013-07-01 02:00:00', end: '2013-07-01 02:59:59' } ]
}
% git diff
diff --git a/ceilometer/storage/impl_mongodb.py b/ceilometer/storage/impl_mongodb.py
index 4580833..84bd8fc 100644
--- a/ceilometer/storage/impl_mongodb.py
+++ b/ceilometer/storage/impl_mongodb.py
@@ -288,6 +288,8 @@ class Connection(base.Connection):
self.db.clear()
else:
self.conn.drop_database(self.db)
+ import time
(if (if 1 2) 1)
Generates the tree
ast.stmt.If
`-> ast.stmt.If
`-> ast.expr.Num
`-> ast.expr.Num
`-> ast.expr.Num
diff --git a/hy/compiler.py b/hy/compiler.py
index 24ba107..22687ca 100644
--- a/hy/compiler.py
+++ b/hy/compiler.py
@@ -157,6 +157,19 @@ class HyASTCompiler(object):
return self._mangle_branch([branch])
@builds("if")
+ def wraps_if_expression(self, expr):
+ return ast.Expr(