Skip to content

Instantly share code, notes, and snippets.

@dirkakrid
dirkakrid / dummy-web-server.py
Created April 16, 2017 10:57 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
@dirkakrid
dirkakrid / howto.md
Created April 13, 2017 14:13
Embed compressed data in HTML

Let's create a file with some data:

echo "here is some data weeeeeeeeeeeeeeeeeeee" > data.tsv

Compress it, encode it with base64, and put it in a javascript variable:

(echo -n "var data = '"; gzip -c data.tsv | base64 -w0; echo -n "'") > data.js

Here's what it looks like now:

Screencapture and animated gifs

I say "animated gif" but in reality I think it's irresponsible to be serving "real" GIF files to people now. You should be serving gfy's, gifv's, webm, mp4s, whatever. They're a fraction of the filesize making it easier for you to deliver high fidelity, full color animation very quickly, especially on bad mobile connections. (But I suppose if you're just doing this for small audiences (like bug reporting), then LICEcap is a good solution).

Capturing (Easy)

  1. Launch quicktime player
  2. do Screen recording

screen shot 2014-10-22 at 11 16 23 am

@dirkakrid
dirkakrid / getallvms.py
Created March 28, 2017 23:53 — forked from pathcl/getallvms.py
getallvms.py
#!/usr/bin/env python
# VMware vSphere Python SDK
# Copyright (c) 2008-2013 VMware, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@dirkakrid
dirkakrid / spam.py
Created March 28, 2017 04:38 — forked from pathcl/spam.py
Spam
#!/usr/bin/env python2.7
# Cuenta correos en spam
#
# Debe instalar 'pygmail':
# pip install pygmail
import gmail
import logging
# logger
function retry-ssh() {
ssh $@
while [ $? -ne 0 ]; do
sleep 3;
ssh $@;
done
}
function ansiblify() {
echo $1 | tr '.-' '_'
@dirkakrid
dirkakrid / lndupes.py
Created March 25, 2017 12:46 — forked from filipenf/lndupes.py
Reads fdupes(-r1) output and create relative symbolic links for each duplicate
#!/usr/bin/env python
# Reads fdupes(-r -1) output and create relative symbolic links for each duplicate
# usage: fdupes -r1 . | ./lndupes.py
import os
from os.path import dirname, relpath, basename, join
import sys
lines = sys.stdin.readlines()
import collections
class DictProxy(collections.Mapping):
"""
A proxy for a dictionary that allows attribute access to underlying keys.
You may pass a custom ``wrapper`` to override the logic for wrapping
various custom types.
"""
import logging
try:
import Queue as queue
except ImportError:
import queue
import threading
class QueueHandler(logging.Handler):
"""
This handler sends events to a queue. Typically, it would be used together
import logging
class QueueHandler(logging.Handler):
"""
This handler sends events to a queue. Typically, it would be used together
with a multiprocessing Queue to centralise logging to file in one process
(in a multi-process application), so as to avoid file write contention
between processes.
This code is new in Python 3.2, but this class can be copy pasted into