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
def sum(l: list): | |
if not l: | |
return 0 | |
i = l.pop() | |
return sum(l) + i | |
print(sum([1,2,3,4,5])) | |
# 15 |
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
var Person = { | |
init: function() { | |
this.first_name = ''; | |
this.last_name = ''; | |
return this; | |
}, | |
getFullName: function() { | |
return this.first_name + ' ' + this.last_name; | |
}, | |
}; |
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.postgresql.org/docs/9.5/functions-json.html | |
WITH | |
virtual_table AS (SELECT key, value FROM jsonb_each('{"k": {"sub_key": 10}, "k2": {"sub_key": 20}}')), | |
extracted_values AS (SELECT value->'sub_key' AS sub_key FROM virtual_table) | |
SELECT * FROM extracted_values |
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
import time | |
from threading import Thread, BoundedSemaphore | |
MAX_CONCURRENT_THREADS = 3 | |
thread_limiter = BoundedSemaphore(value=MAX_CONCURRENT_THREADS) | |
class MyThread(Thread): | |
def run(self): | |
thread_limiter.acquire() |
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
"""Slack notification | |
This needs: | |
- requests==2.11.1 | |
- slackclient==1.3.1 | |
""" | |
import logging | |
import os | |
from socket import gethostname |
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
def zero_or_number(maybe_number): | |
if str(maybe_digit).isdigit(): | |
return maybe_number | |
return 0 |