This file contains hidden or 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
| #Graph G | |
| #1 2 | |
| #2 4 3 5 6 | |
| #4 10 | |
| # | |
| #u = 1 | |
| #v = 10 | |
| import random |
This file contains hidden or 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
| docker run --net=host -t leaderboard sh -c 'python manage.py generate_contributors 100 100' |
This file contains hidden or 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
| { | |
| "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/", |
This file contains hidden or 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
| @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', |
This file contains hidden or 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
| docker run -t leaderboard python manage.py raven test |
This file contains hidden or 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
| 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 }; |
This file contains hidden or 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 MyModel(models.Model): | |
| name = models.CharField() | |
| @property | |
| def github_contributors(self): | |
| return github.get_contributors(self.github_user, self.github_repo) | |
| class MyModelSerializer(Serializer): |
This file contains hidden or 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
| 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() |
This file contains hidden or 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
| { | |
| url: ….. | |
| title: ….. | |
| etc: …. | |
| rssfeed: [ | |
| { | |
| url: …. | |
| title: …. | |
| image: …. | |
| }, |
This file contains hidden or 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
| 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, |