Skip to content

Instantly share code, notes, and snippets.

@eestrada
eestrada / force_iter.py
Last active Nov 3, 2021
Example(s) of how to force iteration of lazy iterators.
View force_iter.py
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
@eestrada
eestrada / safe_mkdir.py
Created Feb 12, 2021
Safely clean up a newly created directory when an exception is raised.
View safe_mkdir.py
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
@eestrada
eestrada / win_env.py
Last active Nov 4, 2021
Pythonic interface to the global and user environment variables on Windows.
View win_env.py
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
@eestrada
eestrada / cleantemp.cmd
Last active Sep 13, 2019
The "Downloads" folder is a bloat trap for random files. Treat it like a temp directory and clean it every startup.
View cleantemp.cmd
:: This is free and unencumbered software released into the public domain
:: using the Unlicense. Please refer to <http://unlicense.org/>
:: This script will completely delete and then recreate your "Downloads" and "Temp" folders in your home directory.
:: This should work for pretty much any NT based version of Windows. If you are still on Windows 9x for some reason, I am sorry.
:: Place this file in "%HOMEDRIVE%%HOMEPATH%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\cleantemp.cmd"
:: or similar to have it run automatically at startup.
:: If, like me, you like to have an explicit Temp directory in your home folder. If not, delete or comment this out.
@eestrada
eestrada / unicode_whitespace.py
Last active Sep 13, 2019
Small gist for how to compute unicode whitespace (since it doesn't exists as a constant like `string.whitespace` does)
View unicode_whitespace.py
# This is free and unencumbered software released into the public domain
# using the Unlicense. Please refer to <http://unlicense.org/>
def _unicode_whitespace():
# Yes, it is bad practice to import modules in a function,
# but we are trying to avoid leaving garbage around once we are done generating our values.
import re
import sys
ws_re = re.compile(r'\s')
@eestrada
eestrada / noise.sh
Created Oct 13, 2017 — forked from rsvp/noise.sh
noise : relaxing ambient Brown noise generator (cf. white noise) | Linux bash script using sox | CogSci notes
View noise.sh
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2011-10-04
#
# _______________| noise : ambient Brown noise generator (cf. white noise).
#
# Usage: noise [minutes=59] [band-pass freq center=1786] [wave]
# ^minutes can be any positive integer.
# Command "noise 1" will display peak-level meter.
#
# Dependencies: play (from sox package)
@eestrada
eestrada / .gitignore
Created Oct 4, 2017 — forked from sevko/README.md
simple Python raytracer
View keybase.md

Keybase proof

I hereby claim:

  • I am eestrada on github.
  • I am eestrada (https://keybase.io/eestrada) on keybase.
  • I have a public key ASCTNsS-svtJ6qajCzUfiRVAcnbPfIt-EVZkH2AA6UH8Vgo

To claim this, I am signing this object:

@eestrada
eestrada / flask_server.py
Created May 11, 2017 — forked from tschieggm/flask_server.py
Stackdriver webhook server example
View flask_server.py
import string
import sys
import logging
import json
from flask import Flask
from flask import Response, request
logger = logging.getLogger(__name__)
logger.info("Stackdriver webhook-sample starting up on %s" % (string.replace(sys.version, '\n', ' ')))
@eestrada
eestrada / data_structures.py
Last active May 2, 2022
A collection of useful data structures including a very complete linked list class that implements the full feature set of _collections.MutableSequence.
View data_structures.py
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit