Skip to content

Instantly share code, notes, and snippets.

@optilude
optilude / value.py
Last active January 19, 2016 22:51
def resolve_field_value(self, issue, field_name):
field_value = getattr(issue.fields, field_name)
if field_value is None:
return None
value = getattr(field_value, 'value', field_value)
if isinstance(value, (list, tuple)):
if len(value) == 0:
2016-01-05 23:23:13,486:DEBUG:letsencrypt.cli:Root logging level set at -20
2016-01-05 23:23:13,501:INFO:letsencrypt.cli:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2016-01-05 23:23:13,517:DEBUG:letsencrypt.cli:letsencrypt version: 0.2.0.dev0
2016-01-05 23:23:13,534:DEBUG:letsencrypt.cli:Arguments: ['-vvvvv', '--debug', '--renew-by-default', '--webroot', '--webroot-path', '/webroot', '--domain', 'cloud.mydomain.net', '--domain', 'router.mydomain.net', '--domain', 'nas.mydomain.net', '--email', '[email protected]', '--agree-tos']
2016-01-05 23:23:13,549:DEBUG:letsencrypt.cli:Discovered plugins: PluginsRegistry(PluginEntryPoint#nginx,PluginEntryPoint#standalone,PluginEntryPoint#manual,PluginEntryPoint#webroot,PluginEntryPoint#apache,PluginEntryPoint#null)
2016-01-05 23:23:13,564:DEBUG:letsencrypt.cli:Requested authenticator webroot and installer None
2016-01-05 23:23:13,579:DEBUG:letsencrypt.plugins.webroot:Creating root challenges validation dir at /webroot/.well-known
@optilude
optilude / client:entry.js
Created October 26, 2015 11:00
Webpack vs. React
// Polyfill ES6 for older browsers
import 'babel/polyfill';
// Trigger globals / methods
import 'simon/client/startup';
import './routes';
@optilude
optilude / jiraquery.py
Created August 6, 2015 22:18
jiraquery.py
# query.py
import itertools
import datetime
import dateutil.parser
import dateutil.tz
def to_datetime(date):
"""Turn a date into a datetime at midnight.
"""
from .query import QueryManager
import pandas as pd
import numpy as np
class StatusTypes:
backlog = 'backlog'
accepted = 'accepted'
complete = 'complete'
class CycleTimeQueries(QueryManager):

I’m querying an issue tracking system for a set of issues

The way the data comes back, I know when the issue was created and when it was changed, so I can iterate over all lifetime events for all issues.

I want to do some calculations like “how many open issues were there in each of the weeks from the start of the project until today”

To do this, I’m creating a DataFrame, initially populated with NaNs, with a multi-index on all the days the project has been live and all the issues found (some of which won’t have existed for each day)

lifetime_days = pd.date_range(start_date, datetime.date.today())

issue_keys = sorted(map(lambda s: s.key, issues))

@optilude
optilude / index.jsx
Created February 7, 2015 19:32
Routing triggers action
var React = require('react');
var Router = require('./router');
var NavigationActionCreators = require('./navigation/navigationActionCreators');
Router.run(function(Handler, state) {
NavigationActionCreators.routerNavigate(Handler, state);
React.render(<Handler />, document.body);
});
define([
'jquery',
'underscore',
'app/app',
'moment',
'numeral',
'app/utils/dateutils',
'jquery.handsontable',
'bootstrap.datepicker'
syncModels: function(model, collection, where, include, keep) {
var collectionItems = {}, // lookup: id -> item from client
toUpdate = {}, // lookup: id -> db model
toCreate = [], // models
toDelete = []; // models
include = include || [];
// keep track of models we are updating
collection.forEach(function(item) {
loadReferenceData: function() {
var self = this;
return Promise.join(
self.getSharedUsers()
.then(function(sharedUsers) {
self.sharedUsers = sharedUsers;
}),