Skip to content

Instantly share code, notes, and snippets.

View dcramer's full-sized avatar
💭
I may be slow to respond.

David Cramer dcramer

💭
I may be slow to respond.
View GitHub Profile
import responses

@responses.activate
def test_my_api():
    responses.add(responses.GET, 'http://twitter.com/api/1/foobar',
                  body='{"error": "not found"}', status=404,
                  content_type='application/json')
# supervisor
[sentry]
numprocs=10
command=uwsgi --addr=0.0.0.0:90%(process_num)02d
# when you restart it does them in batches, instead of one at a time
$ sudo supervisorctl restart sentry
- stops all 10 procs
var Changes = angular.module('Changes', ['ngAnimate', 'ngRoute']).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/', {
templateUrl: 'partials/change-list.html',
resolve: {
initialData: function($http) {
return $http.get('/api/0/changes/');
}
},
<section ng-controller="ChangeListCtrl">
<table class="change-list table table-striped">
<tbody>
<tr class="status-{{change.lastBuild.status.id}} result-{{change.lastBuild.result.id}}"
ng-repeat="change in changes | orderBy:dateModified:true" ng-animate="'animate-fade'">
<td>
<div class="indicator" title="{{change.lastBuild.result.name}}">
<div data-result="{{change.lastBuild.result.id}}"
data-value="{{change.lastBuild.progress}}" ng-radial-progress-bar>&nbsp;</div>
</div>
@dcramer
dcramer / gist:6682862
Created September 24, 2013 10:19
TIL use 'while 1' instead of 'while True'
dcramer:buildbox in ~/Development/buildbox on git:master
$ python -m timeit '(True and "pass")'
10000000 loops, best of 3: 0.0512 usec per loop
dcramer:buildbox in ~/Development/buildbox on git:master
$ python -m timeit '(True and "pass")'
10000000 loops, best of 3: 0.049 usec per loop
dcramer:buildbox in ~/Development/buildbox on git:master
$ python -m timeit '(True and "pass")'
$ pip install --help
Usage:
pip install [options] <requirement specifier> ...
pip install [options] -r <requirements file> ...
pip install [options] [-e] <vcs project url> ...
pip install [options] [-e] <local project path> ...
pip install [options] <archive url/path> ...
Description:
Jenkins EC2 plugin should not re-render sensitive values:
- access key
- secret key
- private key
def Enum():
class GettattrDefaultDict(defaultdict):
def __getattr__(self, name):
return self[name]
return GettattrDefaultDict(iter(xrange(sys.maxint)).next)
Status = Enum()
searching for changes
new remote heads on branch '0.7-split'
new remote head cbf3626ac582
abort: push creates new remote head cbf3626ac582 on branch '0.7-split'!
(did you forget to merge? use push -f to force)
searching for changes
new remote heads on branch '0.7-split'
new remote head cbf3626ac582
abort: push creates new remote head cbf3626ac582 on branch '0.7-split'!
(did you forget to merge? use push -f to force)