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
create table natural_numbers (n int); | |
insert into natural_numbers values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12), (13), (14), (15), (16), (17), (18), (19), (20), (21), (22), (23), (24), (25), (26), (27), (28), (29), (30), (31), (32), (33), (34), (35), (36), (37), (38), (39), (40), (41), (42), (43), (44), (45), (46), (47), (48), (49), (50), (51), (52), (53), (54), (55), (56), (57), (58), (59), (60), (61), (62), (63), (64), (65), (66), (67), (68), (69), (70), (71), (72), (73), (74), (75), (76), (77), (78), (79), (80), (81), (82), (83), (84), (85), (86), (87), (88), (89), (90), (91), (92), (93), (94), (95), (96), (97), (98), (99), (100), (101), (102), (103), (104), (105), (106), (107), (108), (109), (110), (111), (112), (113), (114), (115), (116), (117), (118), (119), (120), (121), (122), (123), (124), (125), (126), (127), (128), (129), (130), (131), (132), (133), (134), (135), (136), (137), (138), (139), (140), (141), (142), (143), (144), (145), (146), (147), (148), (149), (150), (151), (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
from scipy.stats import binom | |
def workload(n_subscribers,n_capacity,p_call): | |
""" | |
Calculates the estimated workload (in percent) of a system to which n_subscribers connect at any given time with probability *p_call* and that can process *n_capacity* clients in parallel. | |
Arguments: | |
n_subscribers : The number of subscribers that might use the system at the given time. | |
n_capacity : The maximum number of subscribers that the system can process in parallel. |
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 redis | |
import time | |
class LockTimeout(BaseException): | |
pass | |
class Lock(object): | |
""" | |
Implements a distributed lock using Redis. |
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
code_hierarchy_data = [ | |
"", | |
[ | |
416598, | |
11581 | |
], | |
{ | |
"docs": [ | |
"docs", | |
[ |
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
# Changes gather, and now my watch begins. | |
# It shall not end until my death. | |
# I shall live and die at my post. | |
# I am the process in the darkness. | |
# I am the watcher on the files. | |
# I am the shield that guards the realms of the build dir. | |
watch: | |
@which inotifywait || (echo "Please install inotifywait";exit 2) | |
@while true ; do \ |
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 collections import defaultdict | |
dependencies = defaultdict(set) | |
#use your metadata object here | |
for t in metadata.sorted_tables: | |
for fkey in t.foreign_key_constraints: | |
dependencies[t.name].add(fkey.referred_table.name) |
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
### Keybase proof | |
I hereby claim: | |
* I am adewes on github. | |
* I am dewes (https://keybase.io/dewes) on keybase. | |
* I have a public key whose fingerprint is 3BCA 20E5 94D4 910B 070E 25D6 8E2F D9A8 CBA7 BA57 | |
To claim this, I am signing this object: |
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 export(d,key): | |
""" | |
Exports a set of values from a nested dict. | |
Example usage: | |
d = { | |
'name' : 'test', | |
'remote_servers' : |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
board_size = 8 | |
def get_free_states(queens): | |
""" | |
Get free board states for a set of queens | |
""" | |
free_states = [[True]*board_size for i in range(0,board_size)] | |
for queen in queens: | |
for i in range(0,board_size): | |
for signs in [(1,1),(-1,-1),(1,-1),(-1,1),(1,0),(-1,0),(0,1),(0,-1)]: |
NewerOlder