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
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
const ( | |
diff = 0.00000001 | |
) |
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
from time import clock | |
from random import randint | |
from collections import namedtuple | |
MASS = [randint(0, 9456) for i in range(10000)] | |
def find_the_smallest_index(mass: list) -> int: | |
the_smallest_index = 0 | |
for index in range(len(mass)): |
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
from time import clock | |
from collections import namedtuple | |
FACTORIAL_NUMBER = 12 | |
def factorial(x: int) -> int: | |
if x < 1: | |
raise Exception('The number should be grater than 1') |
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
from time import clock | |
from random import randint | |
MASS = [randint(0, 9456) for i in range(10000)] | |
def find_the_smallest_index(mass: list) -> int: | |
the_smallest_index = 0 | |
for index in range(len(mass)): | |
if mass[index] < mass[the_smallest_index]: |
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 collections import namedtuple | |
MASS = range(1000000000) | |
SEARCHED_ITEM = 256879 | |
def binary_search(my_list: list, searched_item: int) -> int or None: | |
start = 0 | |
end = len(my_list) - 1 |
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 requests | |
def get_scan_id(url: str) -> int: | |
""" | |
Response example: | |
>>>requests.get('http://.../sequence/v1/generateid?sequenceName=assignments') | |
{"counter":{"_id":"assignments","seq":401865077},"message":"ok"} | |
""" | |
try: |
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
from math import sqrt | |
from random import uniform | |
from decimal import Decimal | |
c_min = 20 | |
c_max = 125 | |
max_count = 1000000 | |
c1 = 145 | |
c2 = 70 | |
c3 = 80 |
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 smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
SENDER_EMAIL = '[email protected]' | |
SENDER_PASSWORD = 'some_password' | |
SERVER = 'smtp.gmail.com:587' | |
RECEIVER_EMAIL = '[email protected]' | |
SUBJECT = 'BLA-bla' |
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
""" | |
requirements: requests-html==0.9.0 | |
runtime: python-3.6 | |
How to use: | |
1. Download these spotify pages as html source from your browser: albums (https://open.spotify.com/collection/albums), | |
artists (https://open.spotify.com/collection/artists) and songs (https://open.spotify.com/collection/tracks) | |
to the relevant directories (scroll all the pages in advance). | |
2. Enter your local paths to the pages under the constant values (ARTISTS_PAGE_PATH, ALBUMS_PAGE_PATH, SONGS_PAGE_PATH). | |
3. Run the script. |
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 string | |
def _remove_non_ascii(text: str): | |
return ''.join(ch for ch in filter(lambda x: x in string.printable, text)) if isinstance(text, str) else text | |
_remove_non_ascii('¬äºé”æåº - 西éåº (å°åå¸) Wonstar - Ximen') # output: ' - () Wonstar - Ximen' |