Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/env python
#-*-coding: utf-8 -*-
import sys
import ctypes
import struct
ELF_MAGIC = [0x7F, ord('E'), ord('L'), ord('F')]
PT_INTERP = 3
ELFCLASS32 = 1
@giannisp
giannisp / gist:ebaca117ac9e44231421f04e7796d5ca
Last active March 1, 2024 14:39
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@damonjw
damonjw / LICENSE
Last active March 23, 2024 10:28
Event driven simulator in Python, using async/await
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.
@markjlorenz
markjlorenz / simple-exec-with-docker-remote-api.sh
Created July 23, 2016 16:05
Using the exec command with the docker API, and capturing output
#! /usr/bin/env bash
# Create the container with a long running process. If PID1 exists before
# we send the exec commands, they will fail because the container is not running
#
CONTAINER_NAME="TEST-`uuidgen`"
curl --silent --unix-socket /var/run/docker.sock "http:/containers/create?name=${CONTAINER_NAME}" -XPOST \
-H "Content-Type: application/json" \
-d '{
"Image": "ruby:latest",
@ArturT
ArturT / Fix OpenSSL Padding Oracle vulnerability (CVE-2016-2107) - Ubuntu 14.04
Last active June 20, 2018 11:46
Fix OpenSSL Padding Oracle vulnerability (CVE-2016-2107) - Ubuntu 14.04
# Based on http://fearby.com/article/update-openssl-on-a-digital-ocean-vm/
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ wget ftp://ftp.openssl.org/source/openssl-1.0.2h.tar.gz
$ tar -xvzf openssl-1.0.2h.tar.gz
$ cd openssl-1.0.2h
$ ./config --prefix=/usr/
$ make depend
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''Output:
$ py fun_with_progress.py
Start doing things without bar ...
Took: 0:00:13.598943
Start doing things with bar ...
@kennethreitz
kennethreitz / check.sh
Created February 7, 2016 15:48
How to find out why your RST isn't rendering on PyPi
pip install readme-renderer && python setup.py check -rs
@thenewguy
thenewguy / middleware.py
Created January 17, 2016 22:54
static serve middleware based off whitenoise
import mimetypes
import time
from os.path import splitext
from django.contrib.staticfiles.storage import staticfiles_storage
from django.http import HttpResponse, FileResponse, HttpResponseNotAllowed, Http404
from django.core.exceptions import SuspiciousFileOperation
from django.conf import settings
from django.utils.six import text_type
from django.utils.http import http_date
@tevino
tevino / fix_virtualenv
Last active March 24, 2024 09:41
Fix python virtualenv after python update
#!/usr/bin/env bash
ENV_PATH="$(dirname "$(dirname "$(which pip)")")"
SYSTEM_VIRTUALENV="$(which -a virtualenv|tail -1)"
BAD_ENV_PATHS="/usr/local"
echo "Ensure the root of the broken virtualenv:"
echo " $ENV_PATH"
@samhocevar
samhocevar / gist:00eec26d9e9988d080ac
Last active January 13, 2024 23:40
Configure sshd on MSYS2 and run it as a Windows service
#!/bin/sh
#
# msys2-sshd-setup.sh — configure sshd on MSYS2 and run it as a Windows service
#
# Please report issues and/or improvements to Sam Hocevar <sam@hocevar.net>
#
# Prerequisites:
# — MSYS2 itself: http://sourceforge.net/projects/msys2/
# — admin tools: pacman -S openssh cygrunsrv mingw-w64-x86_64-editrights
#