Skip to content

Instantly share code, notes, and snippets.

View michael-lazar's full-sized avatar
🎾

Michael Lazar michael-lazar

🎾
View GitHub Profile
import os
import simplejson as json
import urllib, urllib2
from datetime import datetime
# Generate your own key from..
# http://www.wunderground.com/weather/api/
API_KEY = '<your api key here>'
def get_webcams(area_code, api_key):
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):
@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:
# 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 / 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 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
"""
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
@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
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 / alternatives_to_rtv.md
Last active June 16, 2024 04:38
Alternatives to RTV