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 Pool: | |
def __init__(self, | |
connection_factory, | |
target_size=0, | |
decay_time=0): | |
self.connection_factory = connection_factory | |
self.target_size = target_size | |
self.decay_time = decay_time | |
self._connections = {} | |
self.pool_lock = RLock() |
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
scratch=# CREATE TABLE bub (bub_id UUID PRIMARY KEY DEFAULT uuid_generate_v4()); | |
CREATE TABLE | |
scratch=# CREATE TABLE foo (foo_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), bub_id UUID NOT NULL REFERENCES bub (bub_id) ON DELETE CASCADE); | |
CREATE TABLE | |
scratch=# CREATE TABLE subfoo (message TEXT) INHERITS (foo); | |
CREATE TABLE | |
scratch=# insert into bub DEFAULT VALUES; | |
INSERT 0 1 | |
scratch=# insert into bub DEFAULT VALUES; | |
INSERT 0 1 |
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
# I was looking for a rate limiting library to call rate limited apis as closely | |
# as possible to their enforced limits. I looked at the first few python libraries | |
# that I found, and when I glanced at the source, they were all clearly broken. | |
# Curious how this could be, I took all the top google and pip search results for: python rate limiting | |
# and tried to get them to do the wrong thing and fail to rate limit in situations that could come up | |
# in normal use (though in some cases very specific use) | |
# https://github.com/tomasbasham/ratelimit | |
# Where broken: |
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
file |
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 numpy as np | |
from itertools import groupby | |
def fuck_my_face(): | |
A = np.ones((5, 2)) # A is array([[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) | |
B = np.ones((5, 2)) # B is array([[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) |
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
cramdb=# select d->'isbn_10' from bub where d ? 'isbn_10' limit 5; | |
?column? | |
------------------------------ | |
["0521641985", "0521645719"] | |
["039455583X"] | |
["0738706884"] | |
["1603200495"] | |
["0665890753"] | |
(20 rows) |
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
inline vector<string> glob(string pattern, bool only_files = false) { | |
unique_ptr<glob_t, decltype(&globfree)> glob_buffer(new glob_t(), globfree); | |
glob(pattern.c_str(), GLOB_TILDE, NULL, glob_buffer.get()); | |
strings fns; | |
for (size_t i = 0; i < glob_buffer->gl_pathc; ++i) { | |
fns.push_back(string(glob_buffer->gl_pathv[i])); | |
} |
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 os.path import join as join_path | |
from os import listdir | |
from os import mkdir | |
from os.path import exists as path_exists | |
from os.path import expanduser | |
from OpenSSL.crypto import X509Extension | |
from OpenSSL.crypto import X509 | |
from OpenSSL.crypto import dump_privatekey | |
from OpenSSL.crypto import dump_certificate |
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
rt.local (0.0.0.0) Mon Jun 16 21:09:50 2014 | |
Keys: Help Display mode Restart statistics Order of fields quit | |
Packets Pings | |
Host Loss% Snt Last Avg Best Wrst StDev | |
1. router.asus.com 0.0% 60 3.4 0.9 0.7 3.4 0.5 | |
2. 24.7.116.1 30.5% 60 27.5 12.2 9.0 27.8 6.0 | |
3. te-0-2-0-11-sur03.sanjose.ca.sfba.comcast.net 33.9% 60 9.5 11.7 9.1 47.0 6.9 | |
4. te-1-13-0-0-ar01.sfsutro.ca.sfba.comcast.net 23.7% 60 11.8 18.1 10.6 102.5 15.0 | |
5. he-3-10-0-0-cr01.sanjose.ca.ibone.comcast.net 25.4% 59 32.5 22.1 12.2 105.1 23.1 | |
6. be-15-pe02.11greatoaks.ca.ibone.comcast.net 22.4% 59 16.3 18.4 15.4 36.7 5.3 |
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
x = 5 | |
def foo(): | |
print x | |
x = 10 | |
print x | |
foo() |
NewerOlder