This file contains 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
"""explore pylint W0640""" | |
# | |
# A test of how a lambda used to filter a list works | |
# when the filter criteria var is defined in a loop. | |
# | |
# This was written because pylint was giving me | |
# warning W0640: cell-var-from-loop | |
# for a use of filter materially similar to the (greatly simplified) | |
# example below, and I wanted to know if it was actually something | |
# to be concerned about. |
This file contains 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
# goal: use nested list comprehension to do the equivalent of groupby | |
# but with unsorted input that can't be changed | |
# | |
# given input like: | |
# [('foo', 1), ('bar', 3), ('foo', 4), ('bar', 2)] | |
# | |
# produce output like: | |
# [[('foo', 1), ('foo', 4)], [('bar', 3), ('bar', 2)]] | |
# | |
# groupby() can do this, but needs its input sorted. Here's how to do |
This file contains 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
// Typescript handles type guards fundamentally differently than it | |
// handles data in the context of a closure. | |
// | |
// This is not new, and was documented at | |
// https://github.com/microsoft/TypeScript/issues/7662 | |
// and | |
// https://github.com/microsoft/TypeScript/issues/8552 | |
// | |
// Demonstration follows. |
This file contains 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
interface namedThing { | |
name: string; | |
val: number; | |
} | |
interface myType { | |
p1: namedThing | null; | |
p2: number; | |
} |
This file contains 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
#! /bin/bash | |
### BEGIN INIT INFO | |
# Provides: YOURAPP | |
# Required-Start: nginx | |
# Required-Stop: | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: The main gunicorn process for YOURAPP | |
# Description: The gunicorn process that receives HTTP requests | |
# from nginx and proxies them to YOURAPP. |
This file contains 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
#!/usr/bin/python | |
# based on https://medium.com/@edwardbenson/how-i-hacked-amazon-s-5-wifi-button-to-track-baby-data-794214b0bdd8 | |
# | |
# This is a quick hack. As such, it: | |
# * lacks exception handling | |
# * has no pretense of object orientation | |
# * needs root privs (for network monitoring) but doesn't do anything | |
# to make that safe (e.g. drop privs, etc.) | |
# * gets configured manually (see below) |