Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am kwarunek on github.
  • I am kwarunek (https://keybase.io/kwarunek) on keybase.
  • I have a public key whose fingerprint is 1498 A1EA CD8D 3D6C F84F 62B0 707B 55C9 4E31 E557

To claim this, I am signing this object:

@kwarunek
kwarunek / sniff.txt
Created April 5, 2016 11:21 — forked from manifestinteractive/sniff.txt
A friendly formatter for curl requests to help with debugging.
\n
============= HOST: ==========\n
\n
local_ip: %{local_ip}\n
local_port: %{local_port}\n
remote_ip: %{remote_ip}\n
remote_port: %{remote_port}\n
\n
======= CONNECTION: ==========\n
\n
@kwarunek
kwarunek / yieldable_asyncio_udp_client.py
Last active October 4, 2018 11:24
Yieldable/awaitable asyncio UDP client (sendto only actually)
import asyncio
import socket
class UDPClient():
def __init__(self, host, port, loop=None):
self._loop = asyncio.get_event_loop() if loop is None else loop
self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self._sock.setblocking(False)
self._addr = (host, port)
@kwarunek
kwarunek / gist:d939ebd9bbea4fa16c85
Last active February 8, 2016 06:08 — forked from nhoad/gist:8966377
Async stdio with asyncio
import os
import asyncio
import sys
from asyncio.streams import StreamWriter, FlowControlMixin
reader, writer = None, None
@asyncio.coroutine
def stdio(loop=None):
@kwarunek
kwarunek / benchmark.py
Created January 19, 2016 13:05 — forked from eamartin/benchmark.py
Python JSON Benchmark
'''cjson, jsonlib, simplejson, and yajl also use C code
demjson did not use C code, but was too painfully slow to benchmark
(took about 20 seconds for these tests)
'''
import json
import sys
import time
with open('doc.json') as f:
import logging
import tornado
import tornado.gen
from tornado.iostream import IOStream
from tornado.ioloop import IOLoop
from tornado.concurrent import Future
import socket
import tornado.ioloop
import tornado.web
import subprocess
from tornado import gen
@tornado.gen.coroutine
def test():
cmd = "echo 'test' | grep test"
data = yield gen.Task(_run, cmd)
print(data)
@kwarunek
kwarunek / gist:560451aff5ff23bf4436
Last active August 29, 2015 14:07 — forked from mcansky/gist:3434417
aws get s3 expired url
# encoding : utf-8
require 'openssl'
require 'digest/sha1'
require 'base64'
module Aws
extend self
def signed_url(path, expire_date)
digest = OpenSSL::Digest::Digest.new('sha1')
can_string = "GET\n\n\n#{expire_date}\n/#{S3_BUCKET}/#{path}"
import itertools
import functools
import fnmatch
import os
from StringIO import StringIO
import yaml
from yaml.parser import ParserError
import voluptuous as V