Skip to content

Instantly share code, notes, and snippets.

View davidbgk's full-sized avatar
🚪
Let’s escape GAFAM+ when/while we can!

David Larlet davidbgk

🚪
Let’s escape GAFAM+ when/while we can!
View GitHub Profile
@davidbgk
davidbgk / webmention.py
Last active July 4, 2022 01:22 — forked from karlcow/webmention.py
Using gunicorn
def server_app(environ, start_response):
method = environ.get('REQUEST_METHOD', 'GET')
if method == 'GET':
return get_response(start_response)
elif method == 'POST':
accept_header = environ.get('HTTP_ACCEPT', '*/*')
post_data = environ.get('wsgi.input').read()
return post_response(start_response, accept_header, post_data)

Guide to how fucked is SSL?

Thanks to Jacob Kaplan-Moss, Donald Stufft, David Reid, Allen Short, Zain Memon, and Chris Armstrong for review.

This is a guide for technical individuals to understand in what circumstances SSL communications are secure against an observer-in-the-middle (for all intents and purposes: the NSA).

from django.db import models
from django.utils.functional import curry
def contribute_to_model(contrib, destination):
"""
Update ``contrib`` model based on ``destination``.
Every new field will be created. Existing fields will have some properties
updated.
@davidbgk
davidbgk / README.md
Created September 8, 2013 09:44 — forked from jpetazzo/README.md

Secure Docker in the wild

Here is a crude recipe to put socat in front of the Docker API. socat will accept HTTPS connections, make sure that the client shows an appropriate certificate, and relay the connection to the UNIX socket.

First things first

// Based off example code from Hal Robertson
// https://github.com/halrobertson/test-restify-passport-facebook
// See discussion: https://groups.google.com/forum/?fromgroups#!topic/passportjs/zCz0nXB_gao
var restify = require('restify')
// config vars
var FB_LOGIN_PATH = '/api/facebook_login'
var FB_CALLBACK_PATH = '/api/facebook_callback'
var FB_APPID = '<<YOUR APPID HERE>>'
@davidbgk
davidbgk / Encbox.md
Created December 5, 2013 10:40 — forked from Tho85/Encbox.md

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
## log via ssh
mkdir modules
## add modules to python path in your .bash_profile
#export PYTHONPATH=~/modules/
# source .bash_profile
## install pip & virtualenv
easy_install-2.6 --install-dir ~/modules -U pip
easy_install-2.6 --install-dir ~/modules -U virtualenv
#! /usr/bin/env python2
import os
import subprocess
import sys
from contextlib import contextmanager
from wheel.install import WheelFile
from wheel.util import matches_requirement
# Single-line version:
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:[a-z]{2,13})(?:[^\s()<>{}\[\]]+|\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\))+(?:\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’])|(?:(?<!@)[a-z0-9]+(?:[.\-][a-z0-9]+)*[.](?:[a-z]{2,13})\b/?(?!@)))
# Commented multi-line version:
(?xi)
\b
( # Capture 1: entire matched URL
(?:

Make it useful

  • Install Package Control. For SublimeText 2, paste the following in Terminal:
import urllib2,os; pf='Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler( ))); open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen( 'http://sublime.wbond.net/' +pf.replace( ' ','%20' )).read()); print( 'Please restart Sublime Text to finish installation')

From here on out, use Package Control to install everything. +Shift+P, then type Install to get a list of installable packages you can 'livesearch through. After installing plugins, they should be running.