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 / recover_source_code.md
Created Apr 4, 2017 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory
View recover_source_code.md

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
View mac-address-spoofer.sh
#/bin/sh
# Instructions:
# 1. Copy this script locally and run the following `chmod +x mac-address-spoofer.sh`
# 2. Later, run the following: `./mac-address.spoofer.sh` and see your MAC address changing.
echo "origin MAC address: " `sudo ifconfig en0 ether | grep ether`
sudo ifconfig en0 ether `openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
echo "new MAC address: " `sudo ifconfig en0 ether | grep ether`
View es6-feature-detection.js
var str = 'class ಠ_ಠ extends Array {constructor(j = "a", ...c) {const q = (({u: e}) => {return { [`s${c}`]: Symbol(j) };})({});super(j, q, ...c);}}' +
'new Promise((f) => {const a = function* (){return "\u{20BB7}".match(/./u)[0].length === 2 || true;};for (let vre of a()) {' +
'const [uw, as, he, re] = [new Set(), new WeakSet(), new Map(), new WeakMap()];break;}f(new Proxy({}, {get: (han, h) => h in han ? han[h] ' +
': "42".repeat(0o10)}));}).then(bi => new ಠ_ಠ(bi.rd));';
try {
eval(str);
} catch(e) {
alert('Your browser does not support ES6!')
}
@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 / setup.py
Created Jan 14, 2017 — forked from anonymous/setup.py
setup.py template
View setup.py
#!/usr/bin/env python
# coding=utf-8
"""
python distribute file
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals, with_statement)
View sw-precache-config.js
swPrecache.write(path.resolve(__dirname, `../public/service-worker.js`), {
cacheId: `know-it-all`,
filename: `service-worker.js`,
stripPrefix: `public/`,
staticFileGlobs: [
`public/app.*.js`, // don't include the polyfills version
`public/*.{html,ico,json,png}`,
],
dontCacheBustUrlsMatching: [
/\.(js|json)$/, // I'm cache busting js and json files myself
@davidbgk
davidbgk / index.html
Created Dec 1, 2016
Test promisified DCL + class init
View index.html
<!DOCTYPE html>
<meta charset=utf-8>
<title>Test promisified DCL + class init</title>
<script src=test.js></script>
<script>
document.ready = new Promise((resolve) =>
document.addEventListener('DOMContentLoaded', resolve))
document.ready.then((event) => new window.Example(event.target).init())
</script>
<p>Hello world</p>
@davidbgk
davidbgk / top-ten.md
Last active Nov 15, 2016
Bonnes pratiques et fichiers issus de #OpenSirene
View top-ten.md

OpenSirene


1. Nommage

Donner un nom explicite aux fichiers générés :

@davidbgk
davidbgk / Preferences.sublime-settings
Created Nov 12, 2016
Current SublimeText preferences
View Preferences.sublime-settings
{
"bold_folder_labels": true,
"show_tab_close_buttons": false,
"ensure_newline_at_eof_on_save": true,
"trim_trailing_white_space_on_save": true,
"show_definitions": false,
"highlight_line": true,
"highlight_modified_tabs": true,
"auto_complete_commit_on_tab": true,
"translate_tabs_to_spaces": true,
You can’t perform that action at this time.