Skip to content

Instantly share code, notes, and snippets.

Michael Floering hangtwenty

Block or report user

Report or block hangtwenty

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hangtwenty
hangtwenty / python_test_impact_analysis.md
Last active Mar 28, 2019
Note on Python TIA (Test Impact Analysis)
View python_test_impact_analysis.md

Question:

What could I try for doing Test Impact Analysis for Python projects?

Answer:

There are a few libraries out there you could try. Here are some entrypoints:

@hangtwenty
hangtwenty / continuous_learning_inflection_point.md
Last active Mar 11, 2019
blog draft: continuous learning is the keystone habit of software development. oh, and the other part: you have to get over yourself!
View continuous_learning_inflection_point.md

I've self-educated as a developer; now almost 10 years into it, it's worked out for me. But why? What was the deciding factor?

Looking back, I think I can see the inflection point.

I had a mentor who helped me use interactive approaches, and test-driven development. This led to a test-driven mindset.

The core of this mindset is the empirical attitude: that you can know nothing without testing. I learned to iterate in a more directed way. And by always beginning with failing tests,

@hangtwenty
hangtwenty / _preserve_ipython_history_TLDR.diff
Last active Apr 18, 2019
preserve ipython history between docker-compose runs (for local/development usage). diff is only approximately two lines
View _preserve_ipython_history_TLDR.diff
diff --git a/local.yml b/local.yml
index b587373..73684bf 100644
--- a/local.yml
+++ b/local.yml
@@ -3,6 +3,7 @@ version: '2'
volumes:
#...
+ ipython_data_local: {}
services:
@hangtwenty
hangtwenty / example.log
Created Nov 6, 2017
temporary - pasting logs for a pull request
View example.log
$ eemeter --log-level=DEBUG --log-console sample
Going to analyze the sample data set
Running a meter for ABC NATURAL_GAS_CONSUMPTION_SUPPLIED
DEBUG 2017-11-05 18:35:05,428 eemeter.ee.meter L408 | evaluate | Running meter for for trace PROJECT_ID_ABC and project ABC
DEBUG 2017-11-05 18:35:05,459 eemeter.processors.location L49 | get_weather_source | Mapped ZIP code 60640 to ISD station 997338
DEBUG 2017-11-05 18:35:05,501 eemeter.weather.noaa L25 | __init__ | Created ISDWeatherSource("997338") using cache: SqlJSONStore("sqlite:////Users/ms/.eemeter/cache/weather_cache.db")
DEBUG 2017-11-05 18:35:05,508 eemeter.weather.noaa L60 | _check_for_recent_data | ISDWeatherSource("997338") will not update 2017 data because the most recent fetch of that data occurred on 2017-11-04, which is more recent than the target date 2017-11-04.
@hangtwenty
hangtwenty / .gitconfig
Last active Sep 10, 2018
snapshot of git config (especially my heap of aliases, some I use all the time, some I almost never use, but eh I just keep them)
View .gitconfig
[user]
; NOT INCLUDED IN THIS FILE TO AVOID CONFUSION. DON'T FORGET TO SET IT UP LOCALLY THOUGH :-)
[push]
default = simple
[core]
editor = vim
pager = less -F -X
[branch]
@hangtwenty
hangtwenty / owasp-risk-rating.html
Created Sep 20, 2017 — forked from ErosLever/owasp-risk-rating.html
This is a quick and dirty OWASP Risk Rating Calculator. (demo: https://tinyurl.com/OwaspCalc )
View owasp-risk-rating.html
<!-- access this at: https://cdn.rawgit.com/ErosLever/f72bc0750af4d2e75c3a/raw/owasp-risk-rating.html -->
<html><head>
<style>
#main{
width: 1200px;
}
table {
width: 98%;
font-size: small;
text-align: center;
@hangtwenty
hangtwenty / test_foo.py
Last active Sep 7, 2017
boilerplate for test module's docstring when using pytest (so I don't have to look up these links each time...)
View test_foo.py
""" Tests for `foo` package.
uses `pytest`. `pytest` resources:
* https://docs.pytest.org/en/latest/
* https://pragprog.com/book/bopytest/python-testing-with-pytest
also uses `responses`, for mocking HTTP exchanges with `requests` library:
* https://github.com/getsentry/responses
@hangtwenty
hangtwenty / remove_punc.py
Created Aug 22, 2017 — forked from kissgyorgy/remove_punc.py
Python: Remove punctuation from string
View remove_punc.py
#http://stackoverflow.com/questions/265960/best-way-to-strip-punctuation-from-a-string-in-python
import re, string
table = string.maketrans("","")
regex = re.compile('[%s]' % re.escape(string.punctuation))
def test_re(s): # From Vinko's solution, with fix.
return regex.sub('', s)
def test_trans(s):
@hangtwenty
hangtwenty / SanitizedString.py
Last active Sep 6, 2017
(OLD; newer version is here: https://github.com/hangtwenty/presswork/blob/master/presswork/text/clean.py ) I wanted to "ensure" strings had been sanitized (avoid running redundantly). This is ONLY ONE type of sanitization, removing control chars (BESIDES NEWLINES), because that is what my current project needed. But I thought the design could be…
View SanitizedString.py
""" throw your strings to SanitizedString and "ensure" they have been sanitized, such as removing control characters.
SanitizedString will avoid running redundantly, by checking type of the input (good for Very Big Strings)
>>> hello = SanitizedString(chr(0) + "hello")
>>> assert hello == "hello"
>>> assert chr(0) not in hello
>>> assert SanitizedString(hello) == hello
at time of writing there is only one sanitization filter in use:
@hangtwenty
hangtwenty / logging.yml
Last active Feb 2, 2018 — forked from OrangeTux/log.yml
A starter config I like for development/non-production Python logging. (in production I use syslog etc instead). Replace filenames as needed - by hand in YAML, or in your setup code.
View logging.yml
version: 1
formatters:
simple:
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
verbose:
format: "%(levelname)-8s %(asctime)s %(name)s %(filename)s:%(lineno)s | %(funcName)s | %(message)s"
very_verbose:
format: "%(levelname)-8s %(asctime)s %(name)s %(pathname)s:%(lineno)s | %(funcName)s | %(message)s"
handlers:
console:
You can’t perform that action at this time.