Skip to content

Instantly share code, notes, and snippets.

View FZambia's full-sized avatar

Alexander Emelin FZambia

View GitHub Profile
@FZambia
FZambia / sanitizer.py
Created May 27, 2013 05:35
lxml html sanitize and autolink
from lxml.html import clean
class Bleacher(clean.Cleaner):
safe_attrs_only = True
safe_attrs = frozenset([
'abbr', 'accept', 'accept-charset', 'accesskey', 'action', 'align',
'alt', 'axis', 'border', 'cellpadding', 'cellspacing', 'char', 'charoff',
'charset', 'checked', 'cite', 'class', 'clear', 'cols', 'colspan',
#!/usr/bin/env python
# encoding: utf-8
import functools
import hashlib
import logging
import tornado.web
import tornado.gen
import tornado.httpclient
import tornado.ioloop
@FZambia
FZambia / fib_gen.go
Last active December 18, 2015 00:59
my first generator in Go - fibonacci sequence
package main
import "fmt"
func fibgen() func() {
a, b := 0, 1
return func() {
sum := a + b
fmt.Println(sum)
a, b = b, sum
@FZambia
FZambia / version_tag.sh
Last active December 18, 2015 02:39
creating tag with version for deploying purposes
function version_tag() {
# Script automatically increments revision in REVISION file.
# Creates tag and pushes it to git origin for deploy.
if [ ! -d .git ]; then
echo "not a git repo"
return
fi
if [ ! -f REVISION ]; then
# create REVISION file with zero version
@FZambia
FZambia / tornado_github_auth.py
Last active April 20, 2021 07:58
tornado github oauth
# coding: utf-8
#
# Copyright (c) Alexandr Emelin. BSD license.
# All rights reserved.
#
"""
class GithubAuthHandler(BaseHandler, auth.GithubMixin):
x_site_token = 'application'
@FZambia
FZambia / sub.py
Last active October 21, 2019 06:47
tornado's Subprocess class usage example. Minimal Tornado's version required - 3.1
from __future__ import print_function
from tornado.gen import Task, Return, coroutine
import tornado.process
from tornado.ioloop import IOLoop
import subprocess
import time
STREAM = tornado.process.Subprocess.STREAM
@FZambia
FZambia / proxy.go
Last active March 7, 2017 10:07
ZeroMQ XPUB/XSUB proxy implemented using golang
package main
import (
"flag"
zmq "github.com/alecthomas/gozmq"
"log"
)
var xpub = flag.String("xpub", "tcp://*:6001", "ZeroMQ XPUB socket address")
var xsub = flag.String("xsub", "tcp://*:6000", "ZeroMQ XSUB socket address")
@FZambia
FZambia / tarantool_queue.py
Last active December 25, 2015 16:49
tarantool queue wrapper
# -*- coding: utf-8 -*-
# client for tarantool's queue
# https://github.com/tarantool/queue
# usage:
# queue = Queue("127.0.0.1", 12013)
# queue.put(data={"foo":"bar"})
# task = queue.take()
import tarantool
@FZambia
FZambia / html.py
Last active December 27, 2015 01:59
utils to clean html
# coding: utf-8
# bleach==1.2.2
# beautifulsoup4==4.3.2
from bleach import clean
from bs4 import BeautifulSoup
ALLOWED_TAGS = [
@FZambia
FZambia / 0_reuse_code.js
Created November 23, 2013 10:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console