This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns the orginal of an integer | |
function getOrdinal(n) { | |
var s = ["th","st","nd","rd"]; | |
var v = n % 100; | |
return (s[(v - 20) % 10] || s[v] || s[0]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 192.168.1.1 ping statistics --- | |
17 packets transmitted, 7 packets received, 58.8% packet loss | |
round-trip min/avg/max/stddev = 157.283/246.130/414.386/74.276 ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this module is leaky | |
// it syncs | |
module.exports = require('./lib/leaky'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dehydrate_images(self, bundle): | |
images = OfferImage.objects.filter(offer=bundle.obj.pk) | |
resource = OfferImageResource() | |
result = [] | |
for image in images: | |
bundle = resource.build_bundle(obj=image, request=bundle.request) | |
data = resource.full_dehydrate(bundle).data | |
data["resource_uri"] = resource.get_resource_uri(image) | |
result.append(data) | |
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FolderManager(models.Manager): | |
# so that we can do Folder.objects... | |
def get_query_set(self): | |
return super(FolderManager, self).get_query_set().filter(is_folder=True) | |
class Folder(Item): | |
''' | |
this class is kind of funny looking because Items cannot have | |
a ForeignKey field pointing to a subclass of itself. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tastypie.resources import ModelResource, ALL_WITH_RELATIONS | |
from people.models import Basket, Person | |
from tastypie import fields | |
from tastypie.authentication import Authentication | |
from tastypie.authorization import Authorization | |
class BasketAuthorization(Authorization): | |
def is_authorized(self, request, object=None): | |
print request | |
if request and hasattr(request, 'user') and hasattr(request.user, 'employer'): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11:32 < hughes> OH FUCK | |
11:32 < hughes> mack: help | |
11:32 < robot5000> PROBLEM i-a56b6ad4 HTTP HTTP CRITICAL: HTTP/1.1 502 Bad Gateway - 323 bytes in 0.145 | |
second response time | |
11:33 < robot5000> PROBLEM i-a76b6ad6 Login CRITICAL - Socket timeout after 10 seconds | |
11:34 < robot5000> PROBLEM i-a56b6ad4 Login CRITICAL - Socket timeout after 10 seconds | |
11:34 < robot5000> PROBLEM i-c75349b6 HTTP CRITICAL - Socket timeout after 10 seconds | |
11:34 < robot5000> PROBLEM i-a76b6ad6 HTTP CRITICAL - Socket timeout after 10 seconds | |
11:34 < robot5000> PROBLEM i-c75349b6 Login CRITICAL - Socket timeout after 10 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ paver test | |
---> pavement.test | |
nosetests | |
..................F.......... | |
====================================================================== | |
FAIL: test_time (tests.utils.test_template.TestHumanize) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "/Users/hughes/Documents/dev/flower/tests/utils/test_template.py", line 51, in test_time | |
humanize(1343911558.305793, type='time')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import simplejson | |
data = { | |
"metric": "your-metric-slug", | |
"value": somevalue, | |
"timestamp": sometime.isoformat() # optional, defaults to now | |
} | |
headers = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.area = d3.svg.area() | |
.interpolate("monotone") | |
.x(function(d) { | |
return this.x(d.x); | |
}.bind(this)) | |
.y0(height) | |
.y1(function(d) { | |
return this.y(d.y); | |
}.bind(this)); |
OlderNewer