Skip to content

Instantly share code, notes, and snippets.

Stefan Foulis stefanfoulis

Block or report user

Report or block stefanfoulis

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
@stefanfoulis
stefanfoulis / jwt_tests.py
Last active May 9, 2019
Create RS256 / RS512 Tokens and private/public keypairs for testing
View jwt_tests.py
import datetime
from typing import Iterable
import os
import uuid
import jwt
import pytz
import time
import calendar
View gist:030d7fa0d6d488c0c31f16652e20dbf4
RUN pipsi install --python=python3 poetry
# It is kind of hard to install from a .tar.gz of the repo if there is no
# setup.py in there.
RUN mkdir -p /tmp/poetry-master && cd /tmp/poetry-master && wget https://github.com/sdispater/poetry/archive/bdd7909ce7cb729975f31bfdbb4c756a1dd914dd.tar.gz && tar -xzvf bdd7909ce7cb729975f31bfdbb4c756a1dd914dd.tar.gz && cd poetry-bdd7909ce7cb729975f31bfdbb4c756a1dd914dd && poetry build && /root/.pipsi/venvs/poetry/bin/pip3 install --upgrade dist/poetry-0.12.4-py2.py3-none-any.whl
View pyproject.toml
[tool.poetry]
name = "app"
version = "0.1.0"
description = ""
authors = ["None"]
[tool.poetry.dependencies]
python = "3.6"
hyper = "^0.7.0"
cryptography = "^2.3"
@stefanfoulis
stefanfoulis / key_requirements_compare.py
Created Nov 7, 2017
Helpers to compare settings and requirements when migrating from a regular project to a divio cloud project
View key_requirements_compare.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pip
import pip.req
import uuid
# from pprint import pprint as pp; import key_requirements_compare; reload(key_requirements_compare); compared=key_requirements_compare.tst(); print(len(compared['old']))
@stefanfoulis
stefanfoulis / docker_for_mac_disk_default_size.md
Last active Jan 17, 2019
How to resize Docker for Mac Disk image and set the default size for new images
View docker_for_mac_disk_default_size.md

Set the default size for new Docker for Mac disk images

UPDATE: The instructions here are no longer necessary! Resizing the disk image is now possible right from the UI since Docker for Mac Version 17.12.0-ce-mac49 (21995).

If you are getting the error: No space left on device

Configuring the qcow2 size cap is possible in the current versions:

# my disk is currently 64GiB
View gist:1c9b46a61beba2e6423caa746006cae0
test_basic (__main__.AWS4Auth_AmzCanonicalPath_Test) ... ERROR
test_handle_basic_quoting (__main__.AWS4Auth_AmzCanonicalPath_Test) ... ERROR
test_handle_path_normalization (__main__.AWS4Auth_AmzCanonicalPath_Test) ... ERROR
test_handle_percent_encode_non_s3 (__main__.AWS4Auth_AmzCanonicalPath_Test) ... ERROR
test_handle_percent_encode_s3 (__main__.AWS4Auth_AmzCanonicalPath_Test) ... ERROR
test_handle_querystring (__main__.AWS4Auth_AmzCanonicalPath_Test) ... ERROR
test_basic (__main__.AWS4Auth_AmzCanonicalQuerystring_Test) ... ok
test_multiple_params (__main__.AWS4Auth_AmzCanonicalQuerystring_Test) ... ok
test_quoting (__main__.AWS4Auth_AmzCanonicalQuerystring_Test) ... ok
test_space (__main__.AWS4Auth_AmzCanonicalQuerystring_Test) ... ok
@stefanfoulis
stefanfoulis / README.md
Created Sep 13, 2016
Snippets for an eventual better django-dbcache app
View README.md

django-dbcache

A django cache backend that treats the db cache as a first class citizen.

The cache backend in django.core.cache.backends.db only works on the default database connection. Using the same connection as for regular model access can cause weird transaction related deadlocks and similar

@stefanfoulis
stefanfoulis / fd.py
Last active Sep 15, 2015
super naive open files check for datadog
View fd.py
from checks import AgentCheck
class FileDescriptorCheck(AgentCheck):
def check(self, instance):
with open('/proc/sys/fs/file-nr', 'r') as fobj:
fd_open, unknown, fd_max = fobj.read().split('\t')
self.gauge('system.fd_open', int(fd_open))
self.gauge('system.fd_max', int(fd_max))
self.gauge('system.fd_open_pct', float(fd_open)/float(fd_max))
@stefanfoulis
stefanfoulis / gist:dda6b4a2ba91a615b9bb
Created May 24, 2015
accessing the django file object
View gist:dda6b4a2ba91a615b9bb
# f is the File model
f = filer.models.File.objects.get(...)
# f.file is a django file field (for images it's an easy-thumbnails image field)
f.file
View delete_docker_logs.sh
find /var/lib/docker/containers/ -type f -name "*.log" -delete
You can’t perform that action at this time.