Skip to content

Instantly share code, notes, and snippets.

View hirokiky's full-sized avatar

Hiroki Kiyohara hirokiky

View GitHub Profile
@hirokiky
hirokiky / kind_of_shit_fluent.conf
Created May 21, 2015 02:46
Fluentd: Enjoy forever. This config causes `stack level too deep (SystemStackError)`. Allof memory willbe eaten, No log will be executed and your server will fail...
<source>
type forward
</source>
<match **>
type record_reformer
renew_record false
enable_ruby true
tag ip_formatted.${tag}
@hirokiky
hirokiky / README.md
Created June 8, 2015 00:31
Dynamic locust tasks

Dynamic tasks for locust.io

Install

pip install locustio

Try it

@hirokiky
hirokiky / easyscript.py
Created June 10, 2015 00:55
Basic form of Python scripts.
"""
Usage
=====
::
$ python easyscript.py 1 2
3
"""
@hirokiky
hirokiky / error.txt
Created June 16, 2015 00:55
Error when updating contents which name is as Unicode.
2015-06-16 09:42:09,565 ERROR [waitress][Dummy-4] Exception when serving /manage/terms/ティ/@@properties
Traceback (most recent call last):
File "/home/hirokiky/dev/deepthought/env/lib/python3.4/site-packages/waitress/channel.py", line 337, in service
task.service()
File "/home/hirokiky/dev/deepthought/env/lib/python3.4/site-packages/waitress/task.py", line 173, in service
self.execute()
File "/home/hirokiky/dev/deepthought/env/lib/python3.4/site-packages/waitress/task.py", line 392, in execute
app_iter = self.channel.server.application(env, start_response)
File "/home/hirokiky/dev/deepthought/env/lib/python3.4/site-packages/pyramid-1.6a1-py3.4.egg/pyramid/router.py", line 223, in __call__
response = self.invoke_subrequest(request, use_tweens=True)
@hirokiky
hirokiky / msgvjson.py
Created July 25, 2015 06:50
msgpack vs json
import msgpack
data = {} # Input large Python dict
import time
import json
print("Dumping")
print("########### msgpack ##############")
print("started")
@hirokiky
hirokiky / README.md
Created October 13, 2015 01:35
Trying falcon for proxy server
@hirokiky
hirokiky / mandnull.js
Created January 20, 2016 15:00
moment.js and null
> var moment = require('moment')
undefined
> null < moment('1970-01-01')
false
> null < moment('1970-01-02')
true
>
@hirokiky
hirokiky / forcecachesession.py
Last active February 1, 2016 08:05
requests.Session to memoize response forcedly, depeding on cachetools library.
import cachetools
import requests
class ForceCacheSession(requests.Session):
""" Force caching requests.Session
* Apply `cachetools.Cache` by `mount_cache()` methoud
* It will cache if the method was GET and status code was 200
* It will apply `res.from_cache` bool value
@hirokiky
hirokiky / tsl_client.py
Created April 28, 2016 08:25
TSL supported WebSocket for docker-py
import docker
class WSFixedClient(docker.Client):
def _create_websocket_connection(self, url):
sslopt = {}
if self.cert:
sslopt["certfile"] = self.cert[0]
sslopt["keyfile"] = self.cert[1]
return websocket.create_connection(
@hirokiky
hirokiky / write_file_to_docker.js
Created May 19, 2016 01:36
Writing files by dockerode
container.exec({Cmd: ['/bin/sh', '-c', 'cat > /path/to/test.txt], AttachStdin: true}, (err, exec) => {
exec.start({hijack: true, stdin: true}, function(err, stream) {
stream.write("Hi there.\n")
});
});