Skip to content

Instantly share code, notes, and snippets.

View silpol's full-sized avatar
🏠
Email is best comm tool.

Andriy Tymchenko silpol

🏠
Email is best comm tool.
View GitHub Profile
@silpol
silpol / tree.md
Last active August 28, 2015 09:28 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@silpol
silpol / uwsgi.conf
Last active August 28, 2015 09:29 — forked from woodb/uwsgi.conf
Configuration file for uWSGI
description "uWSGI"
start on runlevel [2345]
stop on runlevel [06]
respawn
env UWSGI=/usr/bin/uwsgi
env LOGTO=/var/log/uwsgi/emperor.log
exec $UWSGI --master --emperor /etc/uwsgi/apps-enabled --die-on-term --uid nginx --gid nginx --logto $LOGTO
@silpol
silpol / blog.ini
Last active August 28, 2015 09:29 — forked from woodb/blog.ini
uWSGI configuration for simple blog
[uwsgi]
# Variables
base = /var/www/blog
app = simple
# Generic Config
plugins = http,python
home = %(base)/venv
pythonpath = %(base)
socket = /var/www/run/%n.sock
module = %(app)
@silpol
silpol / default.conf
Last active August 28, 2015 09:30 — forked from woodb/default.conf
nginx configuration for uWSGI
server {
listen 80;
server_name blog;
server_name blog.example.com;
root /var/www/blog;
location /static/ {
alias /var/www/blog/static/;
expires 30d;
access_log off;
@silpol
silpol / setup_flask_and_friends.sh
Last active August 28, 2015 09:35 — forked from woodb/setup_flask_and_friends.sh
Shell script to get setup with Flask, nginx and uWSGI on an Amazon EC2 Linux image
#!/bin/bash
#
# Shell script to automatically configure a new Flask, nginx and uWSGI based blog
# on an Amazon EC2 instance.
#
# See http://bit.ly/MeGwjD for more information!
#
# If you are forking this for your own custom configuration script, see the following other gists:
# https://gist.github.com/3071737
# https://gist.github.com/3071739

Keybase proof

I hereby claim:

  • I am silpol on github.
  • I am silpol (https://keybase.io/silpol) on keybase.
  • I have a public key whose fingerprint is 5532 AD83 DBCB 6E8C 531B 3EA4 0AA9 D1D5 A5F0 7F83

To claim this, I am signing this object:

@silpol
silpol / fabfile.py
Created February 2, 2016 19:42 — forked from elliottb/fabfile.py
Example Python Fabric deployment script. Deploys code from a deployment box to a remote host. Usage from command line on the deployment box: fab deploy.
from fabric.api import local, run, env, put
import os, time
# remote ssh credentials
env.hosts = ['10.1.1.25']
env.user = 'deploy'
env.password = 'XXXXXXXX' #ssh password for user
# or, specify path to server public key here:
# env.key_filename = ''
#!/usr/bin/env python
"""A noddy fake smtp server."""
import smtpd
import asyncore
class FakeSMTPServer(smtpd.SMTPServer):
"""A Fake smtp server"""
def __init__(*args, **kwargs):
@silpol
silpol / nginx-uwsgi-python3
Created July 20, 2016 22:00 — forked from simoncoulton/nginx-uwsgi-python3
Setting up Nginx, uWSGI & Python3
======================================
Setting up Nginx, uWSGI and Python3
======================================
First off, I'm traditionally a PHP developer, but am looking at moving across to Python. I really struggled to find decent documentation on how to get a server up and running for deploying Python web applications from the point of view of someone coming from PHP. The main problems I came across with documentation were:
1) Only showed you how to run the server for a single web application.
2) Only showed you how to configure the app, not the server it was running on.
My preferred workflow for development is by setting up a new VM in VMware Fusion and then forwarding through all requests to that VM via /etc/hosts. This might not be the optimal way to get things up and running, but it works for me.
@silpol
silpol / nda2csv.rb
Created January 8, 2017 23:57 — forked from terotil/nda2csv.rb
Processor for Nordea machine readable bank statements (NDA format). Functionally minimal, just enough to outline a friendly interface and be able to export main transaction records to CSV, which is further processable to OFX using https://github.com/terotil/ofxify
require 'date'
module Nordea
module NDA
class Record
def self.parse(str)
self.new(str).normalized
end
def initialize(str)