Skip to content

Instantly share code, notes, and snippets.

💭
(╯°□°)╯︵ ┻━┻

David Larlet davidbgk

💭
(╯°□°)╯︵ ┻━┻
Block or report user

Report or block davidbgk

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
@davidbgk
davidbgk / server.py
Created Apr 11, 2017
An attempt to create the simplest HTTP Hello world in Python3
View server.py
import http.server
import socketserver
from http import HTTPStatus
class Handler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(HTTPStatus.OK)
self.end_headers()
self.wfile.write(b'Hello world')
@davidbgk
davidbgk / fields.py
Created Oct 28, 2010
Easily add an empty choice to a Django ChoiceField
View fields.py
from django import forms
class EmptyChoiceField(forms.ChoiceField):
def __init__(self, choices=(), empty_label=None, required=True, widget=None, label=None,
initial=None, help_text=None, *args, **kwargs):
# prepend an empty label if it exists (and field is not required!)
if not required and empty_label is not None:
choices = tuple([(u'', empty_label)] + list(choices))
@davidbgk
davidbgk / folder2html.md
Last active Jul 8, 2019
Given a folder containing CommonMark files, turn it into HTML.
View folder2html.md

Folder2HTML

Goal

Given a folder containing CommonMark files, turn it into HTML.

Requirements

File structure

@davidbgk
davidbgk / server.py
Created Oct 25, 2011
A very simple HTTP server in Python using wsgiref.simple_server
View server.py
from cgi import parse_qs
from wsgiref.simple_server import make_server
def simple_app(environ, start_response):
status = '200 OK'
headers = [('Content-Type', 'text/plain')]
start_response(status, headers)
if environ['REQUEST_METHOD'] == 'POST':
request_body_size = int(environ.get('CONTENT_LENGTH', 0))
request_body = environ['wsgi.input'].read(request_body_size)
View kerberos.md

Kerberos setup

This guide explains how to set up Kerberos authentication for an HTTP service on a corporate network based on Active Directory.

All instructions will use the following placeholders:

  • COMPANYAD.COM: Windows Domain
  • COMPANYAD: NETBIOS Domain
  • companyad.com: network domain
@davidbgk
davidbgk / mr-robot-religion.txt
Created Jul 23, 2016
Transcript of Mr Robot S02E03 about religion
View mr-robot-religion.txt
Is that what God does?
He helps?
Tell me,
why didn't God help
my innocent friend
who died for no reason
while the guilty roam free?
Okay, fine.
Forget the one-offs.
How about the countless wars
@davidbgk
davidbgk / http_streaming.md
Created Nov 8, 2018 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)
View http_streaming.md

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

View metaphone.py
#!python
#coding= utf-8
# This script implements the Double Metaphone algorithm (c) 1998, 1999 by Lawrence Philips
# it was translated to Python from the C source written by Kevin Atkinson (http://aspell.net/metaphone/)
# By Andrew Collins - January 12, 2007 who claims no rights to this work
# http://www.atomodo.com/code/double-metaphone
# Tested with Pyhon 2.4.3
# Updated Feb 14, 2007 - Found a typo in the 'gh' section
# Updated Dec 17, 2007 - Bugs fixed in 'S', 'Z', and 'J' sections. Thanks Chris Leong!
# Updated June 25, 2010 - several bugs fixed thanks to Nils Johnsson for a spectacular
View redux-light-example.js
const store = createStore((state = { counter: 0 }, action) => {
switch(action.type) {
case "INCREMENT":
return { counter: state.counter + 1 }
case "DECREMENT":
return { counter: state.counter - 1 }
default:
return state
}
})
@davidbgk
davidbgk / nginx.conf
Created May 3, 2018
nginx conf to proxy carto tiles
View nginx.conf
proxy_cache_path /srv/user/cache levels=1:2 keys_zone=tiles-cache:8m max_size=500000m inactive=1000d;
proxy_temp_path /srv/user/cache/tmp;
upstream openaip_backend {
server 1.tile.maps.openaip.net;
server 2.tile.maps.openaip.net;
server 3.tile.maps.openaip.net;
}
upstream cartodb_backend {
You can’t perform that action at this time.