Skip to content

Instantly share code, notes, and snippets.

View ponimas's full-sized avatar
😯
___

Alex ponimas

😯
___
View GitHub Profile
@ponimas
ponimas / ssdpdlistener.hy
Last active September 10, 2017 18:18
logging ssdp messages in local network in hylang
(import asyncio
logging
socket
struct)
(setv *logger-format* "%(asctime)s %(message)s"
log (.getLogger logging))
(.basicConfig logging :format *logger-format* :datefmt "[%H:%M:%S]")
(.setLevel log logging.INFO)
@ponimas
ponimas / ssh-to.py
Created August 8, 2016 08:53
create tmux window with ssh sessions to all hosts in service and syncronized input
#!/usr/bin/env python
# requirements: ansible, libtmux
# you must set env var INVENTORIES_PATH
import argparse
from ansible.inventory import Inventory
import libtmux as tmux
import os
import sys
/*
Name: Base16 Solarized Light
Author: Ethan Schoonover (http://ethanschoonover.com/solarized)
CodeMirror template adapted for IPython Notebook by Nikhil Sonnad (https://github.com/nsonnad/base16-ipython-notebook)
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools)
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
*/
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import, print_function
import gevent
import subprocess
from functools import partial
from six import int2byte, StringIO
import os
import logging
location / {
more_set_headers 'Access-Control-Allow-Origin: $http_origin' 'Access-Control-Allow-Credentials: true';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE, PUT';
add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since';
add_header 'Content-Length' 0;
add_header 'Content-Type' 'text/plain charset=UTF-8';
@ponimas
ponimas / mkdockers.py
Created June 9, 2014 09:19
creating dockers + mongo replicaset using python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: A. Ponimaskin
from __future__ import unicode_literals, absolute_import, print_function
from pymongo import MongoClient
import docker
from six.moves import range
import argparse
from time import sleep
@ponimas
ponimas / mkdockers.sh
Created June 6, 2014 09:50
mongodb replica set + supervisord dev setup
#!/usr/bin/env sh
sudo rm -rf $PWD/devenvs/*/db/*
sudo rm -rf $PWD/devenvs/*/mongodb.conf
sudo rm -rf $PWD/devenvs/*/supervisord.conf
sudo ln $PWD/devenvs/mongodb.conf $PWD/devenvs/n1/
sudo ln $PWD/devenvs/mongodb.conf $PWD/devenvs/n2/
sudo ln $PWD/devenvs/mongodb.conf $PWD/devenvs/n3/
sudo ln $PWD/devenvs/mongodb.conf $PWD/devenvs/n4/
@ponimas
ponimas / dictlike-polymorphic.py
Last active December 11, 2015 13:48
vertical attributes storage
"""
example from sqlalchemy/examples/vertical ported to one column storage
with casts.
"""
from sqlalchemy.orm.interfaces import PropComparator
from sqlalchemy.ext.hybrid import hybrid_property
import logging