Skip to content

Instantly share code, notes, and snippets.

from __future__ import annotations
import asyncio
import time
from functools import partial
from itertools import count
from typing import Callable, AsyncGenerator
OUTPUT: list[int | str] = []
@kupuguy
kupuguy / fizzbuzz.py
Last active September 25, 2017 17:57
Fizzbuzz, Python regex version
'''Fizzbuzz game written using all of the clarity and power of regular expressions.
N.B. the regex uses VERBOSE mode to maximise readability.
'''
import re
PAT = '''^(?:
(?P<_FizzBuzz>
([0369]*0)|
(([147]|[0369]*[147])([0369]|[258][0369]*[147])*(5|([258][0369]*0)))|
(([258]|[0369]*[258]|([147]|[0369]*[147])([0369]|[258][0369]*[147])*([147]|[258][0369]*[258]))
([0369]|[147][0369]*[258]|([258]|[147][0369]*[147])([0369]|[258][0369]*[147])*
@kupuguy
kupuguy / index.html
Created November 10, 2016 14:42
Pure CSS Ticker (Horizontal)
<h1>Pure CSS Ticker (No-JS)</h1>
<h2>A smooth horizontal news like ticker using CSS transform on infinite loop</h2>
<div class="ticker-wrap">
<div class="ticker">
<div class="ticker__item"><img src="http://ichef-1.bbci.co.uk/news/235/cpsprodpb/16663/production/_92374719_mediaitem92374348.jpg" width="100" > Letterpress chambray brunch.</div>
<div class="ticker__item"><img src="http://ichef-1.bbci.co.uk/news/235/cpsprodpb/16663/production/_92374719_mediaitem92374348.jpg" width="100" > Vice mlkshk crucifix beard chillwave meditation hoodie asymmetrical Helvetica.</div>
<div class="ticker__item"><img src="http://ichef-1.bbci.co.uk/news/235/cpsprodpb/16663/production/_92374719_mediaitem92374348.jpg" width="100" > Ugh PBR&B kale chips Echo Park.</div>
<div class="ticker__item"><img src="http://ichef-1.bbci.co.uk/news/235/cpsprodpb/16663/production/_92374719_mediaitem92374348.jpg" width="100" > Gluten-free mumblecore chambray mixtape food truck. </div>
<div class="ticker__item">Authentic bitters seitan pu
@kupuguy
kupuguy / test.py
Created October 21, 2014 12:46
Selenium bug in Python PhantomJS webdriver
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.common.exceptions import TimeoutException
def wait_for_alert(driver):