Skip to content

Instantly share code, notes, and snippets.

View michael-lazar's full-sized avatar
🎾

Michael Lazar michael-lazar

🎾
View GitHub Profile
@michael-lazar
michael-lazar / zero-byte
Created November 11, 2020 18:58
unicode NUL character
# Unicode code point zero (aka ascii NUL control character)
>>> u"\u0000"
# Is only one code-point long
>>> len(u"\u0000")
1
# Encodes to 0x00 in hex (aka 0000 0000 in binary)
>>> u"\u0000".encode("utf-8")
b'\x00'
@michael-lazar
michael-lazar / alternatives_to_rtv.md
Last active August 11, 2024 03:19
Alternatives to RTV
from flask_gopher import GopherExtension, GopherRequestHandler
app = Flask(__name__)
gopher = GopherExtension(app)
@app.route('/')
def index():
return gopher.render_menu(
gopher.menu.query('Enter ticker:', '/result'),
)
@michael-lazar
michael-lazar / parse_log.py
Created April 13, 2018 21:40
Second Measure coding task
#!/usr/bin/env python3
"""
Write a script that, given a web server log file, returns the 10 most
frequently requested objects and their cumulative bytes transferred.
Only include GET requests with Successful (HTTP 2xx) responses.
Resolve ties however you’d like.
Log format:
- request date, time, and time zone
- request line from the client
"""
Synchronize Hue lights to music recorded in real-time from an external device.
"""
import warnings
import logging
import time
from threading import Thread
import phue
# This file contains the default theme for RTV.
#
# Format:
# <element> = <foreground> <background> <attributes>
#
# RTV accepts for the following keywords for the foreground / background:
# - white
# - black
# - green
# - magenta
@michael-lazar
michael-lazar / out.txt
Created June 29, 2017 02:52
Terminfo colors as reported by python curses
# TERM COLORS COLOR_PAIRS
386at 8 64
Apple_Terminal 8 64
Eterm 8 64
Eterm-256color 256 32767
Eterm-88color 88 7744
Eterm-color 8 64
aixterm 8 64
aixterm-16color 16 256
amiga-vnc 16 256
# This configuration file contains the default theme for RTV.
#
# Format:
# Label=ColorForeground,ColorBackground,Modifiers(optional)
#
# The color palette is indexed as follows:
#
# -1: Default
# The system defined default color.
#
@michael-lazar
michael-lazar / map_with.py
Last active August 29, 2015 14:15
Map function for nesting with statements
from contextlib import contextmanager
from copy import copy
@contextmanager
def map_with(funcs, args, init=True):
if init:
funcs, args = copy(funcs), copy(args)
if len(funcs) == 0:
import time
import os.path
import xml.etree.ElementTree as ET
import requests
URL = 'http://xml.pinnaclesports.com/pinnacleFeed.aspx'
PARAMS = {'sportType':'E sports'}
def build_xml(filename):