Skip to content

Instantly share code, notes, and snippets.

View pydanny's full-sized avatar

Daniel Roy Greenfeld pydanny

View GitHub Profile
@jefftriplett
jefftriplett / python-django-postgres-ci.yml
Last active March 27, 2024 04:27
This is a good starting point for getting Python, Django, Postgres running as a service, pytest, black, and pip caching rolling with GitHub Actions.
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
services:
@pydanny
pydanny / django_local_settings.py
Last active December 12, 2018 12:31
running local unverified SSL on Django and Flask (don't do this in production!!!)
from .common import * # noqa
DEBUG = True
INSTALLED_APPS += ('django_extensions',)
# Snip all the other stuff
% Our tocloft configuration
\usepackage{tocloft}
\newlength{\mylen} %% extra space
\setlength{\mylen}{.2cm}
\addtolength{\cftsecnumwidth}{\mylen} % add the extra space after section numbers
\addtolength{\cftsubsecnumwidth}{\mylen} % add the extra space after subsection numbers
% How we load fontspec
@simonw
simonw / recover_source_code.md
Last active January 16, 2024 08:13
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@acdha
acdha / threaded-requests.py
Created May 15, 2015 18:23
Multi-threaded network I/O in Python 2/3
from __future__ import absolute_import, unicode_literals, print_function
from multiprocessing.pool import ThreadPool
import requests
pool = ThreadPool(processes=8)
for response in pool.imap_unordered(requests.get, urls):
print(response.status_code, response.url)
@pydanny
pydanny / fixed_chapter.md
Created April 23, 2015 06:39
LaTeX fix for chapter bork in TOC

Had a problem with one of our chapter titles having a carriage return in the TOC. Just fixed it! How? Changed the chapter header from

\chapter{Fundamentals of Django App \\ Design}

to

\chapter*{Fundamentals of Django App \\ Design}
\addcontentsline{toc}{chapter}{Fundamentals of Django App Design}
@jezdez
jezdez / easter-at-midnight.eml
Created April 4, 2015 22:04
On the feasibility and long term maintainability of Open Source Software created in spare time and the effect on the everyday life of a programmer
Hi,
Thanks for your mail, since you're one of many people asking this
here are the facts about me not having released an update yet:
- I'm aware of the upstream release and the breakage of my software
- I'm working on software like the one you asked about in my spare time
- I have limited spare time since I'm just one person
- I've spent extensive time on the software (see master branch)
but my limited sparetime still ran out eventually
  • Update HISTORY.rst
  • Update version number in my_project/__init__.py
  • Update version number in setup.py
  • Install the package again for local development, but with the new version number:
python setup.py develop
  • Run the tests:
python setup.py test
tap caskroom/cask
install brew-cask
install htop-osx
install hub
install node
install phantomjs
install tmux
install tree
install vagrant-completion
install watch