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 django.core.signing import TimestampSigner | |
TimestampSigner(key="arbitrary key",salt="arbitrary character").sign("hello") | |
# 'hello:1nupuX:K_GIN7mgJdcqxshVqZlqoNPG7jY3whN-oo7RALBuS_E' | |
TimestampSigner(key="arbitrary key",salt="arbitrary character").unsign('hello:1nupuX:K_GIN7mgJdcqxshVqZlqoNPG7jY3whN-oo7RALBuS_E') | |
# 'hello' | |
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 django.utils.crypto import salted_hmac | |
salted_hmac('arbitrary salt', 'hello', secret="arbitrary secret key", algorithm="md5").digest() |
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 django.core import signing | |
signing.dumps('Hello World') | |
# 'IkhlbGxvIFdvcmxkIg:1nuq1R:XGmDLtvO1Ru77QX7trHD5bCzRsaxTQVKTx9Jxv4Wj6A' | |
signing.loads('IkhlbGxvIFdvcmxkIg:1nuq1R:XGmDLtvO1Ru77QX7trHD5bCzRsaxTQVKTx9Jxv4Wj6A') | |
# 'Hello World' | |
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 sensitive_post_parameters(*parameters): | |
""" | |
Indicate which POST parameters used in the decorated view are sensitive, | |
so that those parameters can later be treated in a special way, for example | |
by hiding them when logging unhandled exceptions. | |
Accept two forms: | |
* with specified parameters: |
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 | |
day_price = np.array([[0,7], [1,12], [2,5], [3,3], [4,11], [5, 6], [6,10] ,[7,2], [8,0]]) | |
results = np.zeros((9, 9)) | |
print(results) | |
for buy in day_price: | |
for sell in day_price: | |
if buy[0] < sell[0]: |
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 threading | |
import time | |
def blocking_1(): | |
print("thread start 1") | |
time.sleep(10) | |
print("thread finished 1") | |
def blocking_2(): | |
print("thread start 2") |
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 threading | |
import time | |
def blocking_io(): | |
print("thread start") | |
time.sleep(10) | |
print("thread finished") | |
def main(): | |
t1 = threading.Thread(target=blocking_io, name="blocking_task") |
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 threading | |
import time | |
def blocking_io(): | |
print("thread start") | |
time.sleep(10) | |
print("thread finished") | |
def main(): | |
t1 = threading.Thread(target=blocking_io, name="blocking_task") |
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/bash | |
REQUIREMENTS=""" | |
Django\n | |
daphne\n | |
""" | |
PROJECT_NAME=$1 | |
if [ -z $PROJECT_NAME ] | |
then | |
PROJECT_NAME=test_$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 5 | head -n 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
# my global config | |
global: | |
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. | |
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. | |
# scrape_timeout is set to the global default (10s). | |
# Alertmanager configuration | |
alerting: | |
alertmanagers: | |
- static_configs: |
NewerOlder