Skip to content

Instantly share code, notes, and snippets.

View jd's full-sized avatar
🦾

Julien Danjou jd

🦾
View GitHub Profile
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(
(if (if 1 2) 1)
Generates the tree
ast.stmt.If
`-> ast.stmt.If
`-> ast.expr.Num
`-> ast.expr.Num
`-> ast.expr.Num
% 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
@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' } ]
}
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,
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
@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)
@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 / 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 / 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()