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 typing | |
from cryptography.fernet import Fernet | |
from pydantic import BaseModel | |
from lib.conf import config | |
fernet = Fernet(config.FEED_FERNET_KEY) | |
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
''' | |
Given a non-empty array N, of non-negative integers , the degree of this array is defined as the maximum frequency of any one of its elements. Your task is to find the smallest possible length of a (contiguous) subarray of N, that has the same degree as N. For example, in the array [1 2 2 3 1], integer 2 occurs maximum of twice. Hence the degree is 2. | |
Input | |
Test case input contains 2 lines. | |
First line contains an integer T, representing the number of elements in the array. | |
The second line contains the array N, list of T integers each separated by space. | |
Output |
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
# same implemented in python as a POC | |
N=5 | |
print('_' * 100) | |
offset = 0 | |
for i in range(5-N): | |
offset += 2 ** i | |
for j in range(2 ** i * 2): | |
print('_' * 100) |
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 typing import Optional | |
''' | |
1 | |
/ \ | |
2 2 | |
/ \ / \ | |
1 2 4 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
import logging | |
import re | |
_ph_catcher = re.compile('\\{(\\w+)\\}') | |
def translate_placeholders(query: str, params: Dict[str, Any]) -> Tuple[str, List[Any]]: | |
""" | |
This is a simple translator designed to allow usage of queries like | |
`SELECT a, b, c FROM table WHERE d = {d} AND e = {e}` with parameters in |
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 python3 | |
import csv | |
import requests | |
from bs4 import BeautifulSoup | |
outfile = open('output.csv', 'w') | |
csvwriter = csv.writer(outfile) | |
csvwriter.writerow(['name', 'date', 'address', 'price', 'currency', 'photo', 'url']) | |
session = requests.Session() |
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 | |
# ignore sensors by names (this string must contain full sensor names) | |
IGNORE='INT3400 Thermal acpitz' | |
RED='\033[1;31m' | |
GREEN='\033[1;32m' | |
YELLOW='\033[1;33m' | |
BLUE='\033[1;34m' | |
NC='\033[0m' # No Color |
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
[MASTER] | |
extension-pkg-whitelist=gimpfu | |
[VARIABLES] | |
# List of additional names supposed to be defined in builtins. Remember that | |
# you should avoid to define new builtins when possible. | |
additional-builtins=ADDITION_MODE,ADD_ALPHA_MASK,ADD_ALPHA_TRANSFER_MASK,ADD_BLACK_MASK, | |
ADD_CHANNEL_MASK,ADD_COPY_MASK,ADD_MASK_ALPHA,ADD_MASK_ALPHA_TRANSFER, | |
ADD_MASK_BLACK,ADD_MASK_CHANNEL,ADD_MASK_COPY,ADD_MASK_SELECTION, | |
ADD_MASK_WHITE,ADD_SELECTION_MASK,ADD_WHITE_MASK,ALL_HUES,ALPHA_CHANNEL, |
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
#! venv/bin/python3 | |
import ccxt | |
for cls in ccxt.exchanges: | |
Exch = ccxt.__dict__[cls]({'timeout': 20000}) | |
if not Exch.has['publicAPI']: | |
print('# %s: only private API, skipped' % (cls,)) | |
continue | |
if not Exch.has['fetchCurrencies']: | |
print('# %s: doesn\'t support fetchCurrencies, skipped' % (cls,)) |
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
{ | |
"mongod_log": { | |
"title": "MongoDB server log format", | |
"regex": { | |
"main": { | |
"pattern": "^(?<timestamp>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[,\\.]\\d+\\+\\d+)\\s+(?<level>\\w)\\s+(?<component>\\w+|-)\\s+\\[?(?<context>-?\\w+)?\\]\\s+(?<body>.*)$" | |
} | |
}, | |
"level": { | |
"critical": "F", |