This document contains interesting stuff.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy this file and run mitmproxy like this:: | |
# | |
# mitmproxy -s mitmproxy-quicker.py --mode reverse:http://dummy.invalid | |
# | |
# Then edit the code below. For example, | |
# http://localhost:8080/index.html will serve the HTML page defined below. | |
# mitmproxy will automatically reload the script whenever you save it to disk. | |
# You can specify a real fallback upstream instead of ``dummy.invalid``, | |
# or remove the ``--mode`` option altogether for a regular (forward) proxy. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import types | |
_HTTP_QUOTED_STRING = r'"(?:[^\\"]|\\.)*"' | |
_HTTP_TOKEN = r"[!#\$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+" | |
_PAIR = '{token}=(?:{token}|{quoted_string})'.format( | |
token=_HTTP_TOKEN, quoted_string=_HTTP_QUOTED_STRING) | |
_LEXER_RE = re.compile('{pair}|.'.format(pair=_PAIR)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
socket_prefix=/tmp/geany-$USER | |
socket=$socket_prefix-$RANDOM | |
desktop=$( xdotool get_desktop ) | |
pid=$( xdotool search --desktop "$desktop" --class Geany getwindowpid ) | |
if [[ $pid ]]; then | |
candidate=$( ps -p $pid -o args= | grep -Eo "$socket_prefix-[0-9]+" ) | |
if [[ -e $candidate ]]; then | |
socket=$candidate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
die() | |
{ | |
echo "notdot: $1" >&2 | |
exit 1 | |
} | |
do_add() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To run: install (Ubuntu package names) | |
# ``python3-gi``, ``gir1.2-gtk-3.0``, ``gir1.2-webkit2-4.0``, | |
# then do ``python3 webkitgtk_form.py`` | |
import ctypes | |
import gi | |
gi.require_version('Gtk', '3.0') | |
gi.require_version('WebKit2', '4.0') | |
from gi.repository import Gtk, WebKit2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -G --head httpbin.org/response-headers \ | |
> --data-urlencode 'ETag=W/"foo-bar"' | |
HTTP/1.1 200 OK | |
Server: nginx | |
Date: Sat, 30 Jan 2016 14:08:45 GMT | |
Content-Type: application/json | |
Content-Length: 96 | |
Connection: keep-alive | |
ETag: W/"foo-bar" | |
Access-Control-Allow-Origin: * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(fset 'vf-orig-kill-region (symbol-function 'kill-region)) | |
(defadvice kill-word (before vf-before-kill-word ()) | |
(fset 'kill-region (symbol-function 'delete-region))) | |
(defadvice kill-word (after vf-after-kill-word ()) | |
(fset 'kill-region (symbol-function 'vf-orig-kill-region))) | |
(ad-activate 'kill-word) | |
(defadvice backward-kill-word (before vf-before-backward-kill-word ()) | |
(fset 'kill-region (symbol-function 'delete-region))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import BaseHTTPServer | |
import turq | |
turq.TurqHandler.install_code(''' | |
with path() as r: | |
r.text('blah blah') | |
''') | |
BaseHTTPServer.HTTPServer(('0.0.0.0', 13085), turq.TurqHandler).serve_forever() |
NewerOlder