Skip to content

Instantly share code, notes, and snippets.

Boris Feld Lothiraldan

Block or report user

Report or block Lothiraldan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:87bf5fc9fba604ececa0
from flask import Flask, render_template
app = Flask(__name__)
def gen_page(page):
def endpoint():
return render_template(page, page_name=page)
endpoint.__name__ = page
@Lothiraldan
Lothiraldan / gist:7c295329e7ec4a04d423
Created Apr 11, 2015
Function call in traceback detection
View gist:7c295329e7ec4a04d423
import inspect
import sys
def _get_code_id(callable):
if inspect.ismethod(callable):
return id(callable.im_func.func_code)
elif inspect.isfunction(callable):
return id(callable.func_code)
@Lothiraldan
Lothiraldan / gist:2c9a0f77aa64fc87079f
Created Nov 28, 2014
Oracle java 7 auto-accept SaltStack
View gist:2c9a0f77aa64fc87079f
{% if grains.os_family == 'Debian' %}
java7_read_license:
cmd.run:
- name: "echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections"
- unless: 'debconf-get-selections | grep "shared/accepted-oracle-license-v1-1"'
- require:
- pkg: debconf-utils
- require_in:
- pkg: java7_packages
View gist:b1557ea2a151ffb2c9b3
def recv_future(zmqstream):
''' Retruns future for recv on zmqstream
'''
future = Future()
def _finish(reply):
future.set_result(reply)
zmqstream.on_recv(_finish)
View gist:f359766d1c750f6b6cb2
from tornado.platform.asyncio import AsyncIOMainLoop
import asyncio
import tornado
import tornado.web
import tornado.gen
from inspect import isgeneratorfunction, isgenerator
AsyncIOMainLoop().install()
loop = asyncio.get_event_loop()
@Lothiraldan
Lothiraldan / fabfile.py
Created Feb 7, 2014
FabFile for creating VagrantFile using salt provisionner with pregenerated keys
View fabfile.py
"""Deployment tasks using fabric
"""
import sys
from os.path import join, abspath, dirname, expanduser, exists, normpath
from fabric.api import prompt, env, sudo, put, task, local, run, cd
# from settings import settings
from fabric.colors import green, red
from shutil import copy
@Lothiraldan
Lothiraldan / Output
Last active Dec 29, 2015
Tornado + yield from = <3
View Output
# http://localhost:8888/?mode=sync
http://wikipedia.com code: 200
http://google.com code: 200
http://example.com code: 200
#> time curl http://localhost:8888/\?mode\=sync
http://wikipedia.com code: 200<br/>http://google.com code: 200<br/>http://example.com code: 200curl http://localhost:8888/\?mode\=sync 0,01s user 0,00s system 0% cpu 1,106 total
# http://localhost:8888/?mode=async
View gist:5674257
import sys
import socket
from tornado.web import Application as BaseApplication
from tornado.options import define, options, parse_command_line
class Application(BaseApplication):
def listen(self, port, address="", **kwargs):
if options.fd:
@Lothiraldan
Lothiraldan / gist:5612446
Created May 20, 2013
Fix for circus #403
View gist:5612446
diff --git a/circus/process.py b/circus/process.py
index 070cb10..f7cb699 100644
--- a/circus/process.py
+++ b/circus/process.py
@@ -124,7 +124,7 @@ class Process(object):
if self.uid:
os.setuid(self.uid)
- self._worker = Popen(args, cwd=self.working_dir,
+ self._worker = Popen(args, bufsize=-1, cwd=self.working_dir,
View gist:5612442
diff --git a/circus/process.py b/circus/process.py
index 070cb10..f7cb699 100644
--- a/circus/process.py
+++ b/circus/process.py
@@ -124,7 +124,7 @@ class Process(object):
if self.uid:
os.setuid(self.uid)
- self._worker = Popen(args, cwd=self.working_dir,
+ self._worker = Popen(args, bufsize=-1, cwd=self.working_dir,
You can’t perform that action at this time.