Skip to content

Instantly share code, notes, and snippets.

View phoikoi's full-sized avatar

Peter Hull phoikoi

View GitHub Profile
@phoikoi
phoikoi / 3.11.0
Last active October 25, 2022 15:39
Add this file to ~/.pyenv/plugins/python-build/share/python-build, and then pyenv install 3.11.0
prefer_openssl11
export PYTHON_BUILD_CONFIGURE_WITH_OPENSSL=1
install_package "openssl-1.1.1q" "https://www.openssl.org/source/openssl-1.1.1q.tar.gz#d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca" mac_openssl --if has_broken_mac_openssl
install_package "readline-8.2" "https://ftpmirror.gnu.org/readline/readline-8.2.tar.gz#3feb7171f16a84ee82ca18a36d7b9be109a52c04f492a053331d7d1095007c35" mac_readline --if has_broken_mac_readline
if has_tar_xz_support; then
install_package "Python-3.11.0" "https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tar.xz#a57dc82d77358617ba65b9841cee1e3b441f386c3789ddc0676eca077f2951c3" standard verify_py311 copy_python_gdb ensurepip
else
install_package "Python-3.11.0" "https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz#20d77729a64b2a300f08717f7ffcb8da189d02e7c51e6e4a06c0340b619cbf32" standard verify_py311 copy_python_gdb ensurepip
fi
@phoikoi
phoikoi / django-dev-dockerfile
Last active October 19, 2018 01:51 — forked from spool/Dockerfile
Dockerfile for Django core development in progress from DjangoCon US 2018
# Apparently a very small example
# https://blog.realkinetic.com/building-minimal-docker-containers-for-python-applications-37d0272c52f3
FROM python:3
# Get current version of django
RUN git clone http://github.com/django/django
WORKDIR django
RUN apt-get update && apt-get install -y \
build-essential \
@phoikoi
phoikoi / datetime_range.py
Last active August 2, 2018 18:35 — forked from obeattie/datetime_range.py
A datetime range class for Python, for (obviously) dealing with ranges of datetimes.
"""Provides a `DateTimeRange` class, which is used for managing ranges of datetimes.
Forked from https://gist.github.com/obeattie/213328.
"""
import datetime
class DateTimeRange(object):
"""Represents a range of datetimes, with a start and (optionally) an end.
Basically implements most of the methods on a standard sequence data type to provide
some lovely syntactic sugar. Specifically, you can iterate on this, index it, slice it,
@phoikoi
phoikoi / boiler.py
Created July 20, 2018 05:29
This python script uses Click and jinja2 to give you a super quick way to generate generic HTML pages, with or without jquery and/or bootstrap CSS and JS
#!/usr/bin/env python3
import sys
def die(message):
sys.stderr.write(f"{message}\n")
sys.exit(1)
try:
import click
except ImportError:
@phoikoi
phoikoi / imagewiththumbnails_updateable.py
Created June 21, 2018 05:21 — forked from valberg/imagewiththumbnails_updateable.py
Django create thumbnail form ImageField and save in a different ImageField - now with updating!
# Extension of http://www.yilmazhuseyin.com/blog/dev/create-thumbnails-imagefield-django/
# Note: image_folder and thumbnail_folder are both a callable (ie. a lambda that does a '/'.join())
class Image(Media):
image = models.ImageField(
upload_to=image_folder
)
thumbnail = models.ImageField(
@phoikoi
phoikoi / gist:33d8477a4d1eaaef7bb05247abc20bd4
Created March 11, 2018 03:38
Modified (hacked) handling.cfg from GTA San Andreas (boats are not optimal)
; Author: Bill Henderson
; Created 10/12/1999
;
; > COMMENTS <
; ------------
; TWEAK AT YOUR OWN RISK
;
; > UNITS <
; ---------
; vehicle identifier 14 characters max
@phoikoi
phoikoi / redux_setup.md
Last active February 22, 2018 23:39 — forked from kiok46/redux_setup.md
Redux, store, actions and reducers setup along with explanation.

Redux Setup

Implementation of redux inside any react.js or react-native application,

  • we will create an instance of the redux store.
  • We are going to create a provider tag from react redux library
  • Then render that provider tag passing in the store as a prop, then any child component to this provider tag will have access to this store through the context system inside of react.
  • import { Provider } from ‘react-redux’; // In main.js
  • to create a store create one in a separate folder.
@phoikoi
phoikoi / make_passbook.py
Created March 17, 2017 12:46 — forked from dschuetz/make_passbook.py
Simple hack to create Passbook .pkpass file
import sys, os.path, hashlib, re
import zipfile
import subprocess
from StringIO import StringIO
from io import BytesIO
#
# Passbook Hack
# David Schuetz
# 30 May 2014
@phoikoi
phoikoi / template.html
Created February 13, 2017 02:07
HTML template with bootstrap 4a6
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=">
<title>Placeholder</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<style>
#!/usr/bin/env python
""" Generates an nginx configuration for a given site name (with optional params)
Requirements: jinja2, click
"""
# (c) 2016 Peter Hull, use and redistribution granted under the MIT license:
# https://opensource.org/licenses/MIT
import sys