Skip to content

Instantly share code, notes, and snippets.

View jaredlockhart's full-sized avatar

Jared Lockhart jaredlockhart

View GitHub Profile
#Graph G
#1 2
#2 4 3 5 6
#4 10
#
#u = 1
#v = 10
import random
docker run --net=host -t leaderboard sh -c 'python manage.py generate_contributors 100 100'
{
"https://www.groupon.com/": {
"provider_url": "http://www.groupon.com",
"authors": [],
"provider_display": "www.groupon.com",
"related": [],
"favicon_url": null,
"images": [],
"app_links": [],
"original_url": "http://www.groupon.com/",
@staticmethod
def get_matches_for_hero_id(hero_id):
return (Match.objects
.filter(playerinmatch__hero__pk=hero_id, valid_for_model=True)
.order_by('-match_id')
.prefetch_related(
'playerinmatch',
'playerinmatch__hero',
'playerinmatch__hero',
'playerinmatch__item_0',
docker run -t leaderboard python manage.py raven test
47 function getMetadata(url) {
48 const response = new Promise((resolve, reject) => {
49 jsdom.env({
50 url: url,
51 scripts: [],
52 done: (err, window) => {
53 const metaData = {
54 title: applyRules(window.document, titleRules),
55 canonicalUrl: applyRules(window.document, canonicalRules),
56 };
class MyModel(models.Model):
name = models.CharField()
@property
def github_contributors(self):
return github.get_contributors(self.github_user, self.github_repo)
class MyModelSerializer(Serializer):
MockGithubTestMixin(object)
def setUp(self):
super(MockGithubTestMixin, self).setUp()
mock_github_patcher = mock.patch('scienceapi.utility.github.github')
self.mock_github = mock_github_patcher.start()
self.addCleanup(mock_github_patcher.stop)
mock_contributor = mock.MagicMock()
{
url: …..
title: …..
etc: ….
rssfeed: [
{
url: ….
title: ….
image: ….
},
In [83]: pprint.pprint(json.loads(requests.post('http://cloudvm.jaredkerim.com/', data=json.dumps({'urls': ['https://news.ycombinator.com']}), headers={'content-type':'application/json'}).content))
{u'error': u'',
u'urls': {u'https://news.ycombinator.com': {u'favicon_colors': [{u'color': [252,
100,
4],
u'weight': 0}],
u'favicon_url': u'https://news.ycombinator.com/favicon.ico',
u'image': u'https://news.ycombinator.com/y18.gif',
u'images': [{u'colors': [{u'color': [0,
0,