Skip to content

Instantly share code, notes, and snippets.

View chrislawlor's full-sized avatar

Chris Lawlor chrislawlor

View GitHub Profile
@chrislawlor
chrislawlor / starship.toml
Created September 8, 2022 15:17
Starship Prompt Config
[aws]
format = 'on [$symbol($profile )(\($region\) )]($style)'
style = 'bold blue'
[aws.region_aliases]
eu-west-1 = "ie"
us-east-1 = "us"
[python]
format = '[${symbol}${pyenv_prefix}(${version} )(\($virtualenv\))]($style)'
python_binary = 'python'
@chrislawlor
chrislawlor / LICENSE
Last active June 4, 2023 18:57
Multicast delegates in Python. Uses operator overloading for subscription, C# style.
Copyright 2020 Christopher Lawlor
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE O
@chrislawlor
chrislawlor / LICENSE
Last active April 16, 2020 13:41
Python iterable processing with delayed execution. Inspired by LINQ
Copyright 2020 Christopher Lawlor
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE O
@chrislawlor
chrislawlor / README.md
Last active September 2, 2019 21:52 — forked from denji/README.md
Simple Sentry docker-compose.yml
  1. Download docker-compose.yml to dir named sentry
  2. Change SENTRY_SECRET_KEY to random 32 char string
  3. Run docker-compose up -d
  4. Run docker-compose exec sentry sentry upgrade to setup database and create admin user
  5. (Optional) Run docker-compose exec sentry pip install sentry-slack if you want slack plugin, it can be done later
  6. Run docker-compose restart sentry
  7. Sentry is now running on public port 9000
@chrislawlor
chrislawlor / toggle.py
Created February 27, 2019 16:46
Simple Feature Toggles
"""
This gist is the "guts" of a simple feature toggle implementation.
Toggles are created ad-hoc in application code by instantiating a
``Toggle``, like this:
from toggle import Toggle
my_toggle = Toggle('feature_name')

Keybase proof

I hereby claim:

  • I am chrislawlor on github.
  • I am clawlor (https://keybase.io/clawlor) on keybase.
  • I have a public key ASBGguhM_e404xrczF_PS33eluhEh6fBxCKAOh2JcmrFEwo

To claim this, I am signing this object:

@chrislawlor
chrislawlor / foursquare_category_update.py
Last active October 2, 2017 19:23
Foursquare category update to PostgreSQL table.
"""
Download the category list from Foursquare, and upsert it into
a flat table in a PostgreSQL database.
See https://developer.foursquare.com/docs/venues/categories
1. Create the table with the following DDL statement:
CREATE TABLE foursquare_categories
(
#!/usr/bin/env python
"""
Removes commented lines from an input list of lines.
Commented lines are defined simply as lines that begin with "#" or ";"
Example usage:
uncomment config.ini
@chrislawlor
chrislawlor / gist:8474185
Last active January 3, 2016 14:09
Bash prompt - add Git branch and 'dirty' status, e.g. user@localhost:~/code/project on develop⚡ Add to your ~/.bashrc (linux) or ~/.bash_profile (OSX)
# Custom prompt
function parse_git_dirty {
git branch > /dev/null 2>&1
if [[ $(echo $?) == "0" ]]
then [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "⚡"
fi
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/on \1/"
}
@chrislawlor
chrislawlor / gist:7116554
Created October 23, 2013 10:57
Get database password from ~/.my.cnf file, if it exists. Useful when developing on CloudSQL + AppEngine, which gleefully ignores environment variables.
# Get password from ~/.my.cnf if it exists
my_cnf_path = os.path.expanduser('~/.my.cnf')
if os.path.exists(my_cnf_path):
from ConfigParser import SafeConfigParser
config = SafeConfigParser()
with open(my_cnf_path) as my_cnf:
config.readfp(my_cnf)
try:
DATABASES['default']['PASSWORD'] = config.get('client', 'password')
except ConfigParser.NoOptionError: