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 PyV8 | |
| class Globals(PyV8.JSClass): | |
| def __init__(self): | |
| super(Globals, self).__init__() | |
| self.coords = [] | |
| def PutMarkers(self, selector, coords): | |
| coords = PyV8.convert(coords) |
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
| <html> | |
| <head> | |
| </head> | |
| <canvas id="c" width="800", height="600" style="display: none"></canvas> | |
| <img id="kep"> | |
| <button id="f5">F5</button> | |
| <script> | |
| function newCircle(ctx){ | |
| ctx.beginPath(); |
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
| # coding: utf-8 | |
| import requests | |
| from lxml.html import fromstring | |
| from requests_toolbelt.multipart.encoder import MultipartEncoder | |
| def extract(soup): | |
| for elem in soup.cssselect('.rc h3 a'): | |
| href = elem.get('href') | |
| if 'parom.hu' not in href: |
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
| # coding: utf-8 | |
| import json | |
| import argparse | |
| import os | |
| import re | |
| from pathlib import Path | |
| os.environ.setdefault("DJANGO_SETTINGS_MODULE", "wimm.settings") |
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 re | |
| items = ('burger', 'fries', 'chicken', 'pizza', 'sandwich', 'onionrings', 'milkshake', 'coke') | |
| def get_order(s): | |
| words = re.findall('|'.join(items), s, flags=re.IGNORECASE) | |
| words.sort(key=items.index) | |
| return ' '.join(map(str.capitalize, words)) |
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 longest_palindrome(text): | |
| text_length = len(text) | |
| def find(longest_possible): | |
| for window in range(text_length - longest_possible + 1): | |
| subtext = text[window:window + longest_possible] | |
| if subtext == subtext[::-1]: | |
| return longest_possible | |
| else: | |
| return find(longest_possible - 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 collections | |
| def josephus_survivor(n, k): | |
| population = collections.deque(range(1, n + 1)) | |
| retval = None | |
| while population: | |
| population.rotate(1 - k) | |
| retval = population.popleft() | |
| return retval |
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 collections | |
| def scramble(word, chars): | |
| word_char_count = collections.Counter(word) | |
| chars_char_count = collections.Counter(chars) | |
| chars_char_count.subtract(word_char_count) | |
| return all(chars_char_count[word_char] >= 0 for word_char in word_char_count.keys()) | |
| print(scramble('door', 'abcdeooor')) |
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 re | |
| def patch(match): | |
| incremented = str(int(match.group(0)) + 1) | |
| padded = incremented.zfill(len(match.group(0))) | |
| return padded | |
| def increment_if_ends_with_int(text): | |
| patched = re.sub('(\d+)$', patch, text) | |
| if not patched[-1].isdigit(): |
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 collections | |
| def smallest_unique_number(numbers: list) -> int: | |
| try: | |
| least_common, population = collections.Counter(numbers).most_common()[-1] | |
| assert population == 1 | |
| return least_common | |
| except (AssertionError, IndexError): | |
| return -1 |
OlderNewer