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 __future__ import absolute_import, unicode_literals, print_function | |
from multiprocessing.pool import ThreadPool | |
import requests | |
pool = ThreadPool(processes=8) | |
for response in pool.imap_unordered(requests.get, urls): | |
print(response.status_code, response.url) |
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
#!/usr/bin/env python | |
from __future__ import absolute_import, print_function, unicode_literals | |
import multiprocessing | |
import sys | |
import time | |
import requests |
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
# encoding: utf-8 | |
from __future__ import absolute_import | |
from itertools import count, izip_longest, tee | |
def chunked_iterator(iterable, chunk_size): | |
"""Given an iterator, yield individual items but consume them in chunk_size | |
batches so we can e.g. retrieve records from Solr in 50-100 batches | |
rather than the default 10 |
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
Render using innerHTML took:0.140s; tbody height=536364px | |
Render using DOM took:0.076s; tbody height=536364px | |
Render using React took:1.443s; tbody height=536364px |
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
#!/bin/sh | |
echo "Installing npm dependencies" | |
npm install ~/Projects/bagger-js |
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
--- py-svn.c 2015-02-24 10:10:21.000000000 -0500 | |
+++ py-hg.c 2015-02-24 10:11:11.000000000 -0500 | |
@@ -11,7 +11,7 @@ | |
/* Ensure ob_item has room for at least newsize elements, and set | |
* ob_size to newsize. If newsize > ob_size on entry, the content | |
* of the new slots at exit is undefined heap trash; it's the caller's | |
- * responsiblity to overwrite them with sane values. | |
+ * responsibility to overwrite them with sane values. | |
* The number of allocated elements may grow, shrink, or stay the same. | |
* Failure is impossible if newsize <= self.allocated on entry, although |
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 unittest import mock | |
>>> import json | |
>>> m_o = mock.mock_open() | |
>>> m_o.side_effect = OSError('Insufficient voltage') | |
>>> json.load(m_o('foo.json', 'rb')) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/unittest/mock.py", line 896, in __call__ | |
return _mock_self._mock_call(*args, **kwargs) | |
File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/unittest/mock.py", line 952, in _mock_call |
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
/* jshint esnext:true */ | |
var [foo, bar] = [1, 2]; | |
console.log('Foo is', foo); | |
console.log('Bar is', bar); |
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
from __future__ import absolute_import, print_function, unicode_literals | |
import rdflib | |
g = rdflib.Graph() | |
for code in ('6', '64', '641'): |
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
# encoding: utf-8 | |
from __future__ import absolute_import, division, print_function | |
from itertools import count, izip_longest, tee | |
def chunked_iterator(iterable, chunk_size): | |
"""Given an iterator, yield individual items but consume them in chunk_size | |
batches so we can e.g. retrieve records from Solr in 50-100 batches | |
rather than the default 10 |