Skip to content

Instantly share code, notes, and snippets.

View bitrut's full-sized avatar

Paweł Kowalski bitrut

View GitHub Profile
@bitrut
bitrut / last_commit.py
Created December 18, 2011 20:13
Get timestamp of the last commit in git repository
#!/usr/bin/python
import subprocess
import re
from optparse import OptionParser
def git_version():
p = subprocess.Popen(["git", "log" , '-1', '--date=iso'], stdout=subprocess.PIPE)
out, err = p.communicate()
m = re.search('\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}', out)
@bitrut
bitrut / gist:3135780
Created July 18, 2012 11:59 — forked from rolo/gist:1481128
Install Postgres 9.1, PostGIS and create PostGIS template on a clean Ubuntu 12.04 LTS
#!/bin/bash
sudo apt-get -y install postgresql-9.1 postgresql-server-dev-9.1 postgresql-client-9.1 postgresql-9.1-postgis
sudo su postgres -c'createdb -E UTF8 -U postgres template_postgis'
sudo su postgres -c'createlang -d template_postgis plpgsql;'
sudo su postgres -c'psql -U postgres -d template_postgis -c"CREATE EXTENSION hstore;"'
sudo su postgres -c'psql -U postgres -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql'
sudo su postgres -c'psql -U postgres -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql'
sudo su postgres -c'psql -U postgres -d template_postgis -c "select postgis_lib_version();"'
@bitrut
bitrut / gist:4078437
Created November 15, 2012 12:38
Django ORM console logging
import logging;l = logging.getLogger('django.db.backends');l.setLevel(logging.DEBUG);l.addHandler(logging.StreamHandler())
@bitrut
bitrut / gist:7676303
Last active December 29, 2015 13:19
Desired Angular model example
var person = new Person({firstName: 'John', lastName: 'Smith'}); // Object created on client side without calling API
var promise = person.save(); // $save()? POST request to API to create the object in backend DB
promise.then(function(success){
alert('ok'); // whatever
});
person.firstName = 'Michael';
promise = person.save(); // PUT request to API to update object in the backend
promise.then(function(success){
alert('ok'); // whatever
});
@bitrut
bitrut / consumer.py
Last active October 16, 2017 11:25
aio-pika issue #71: Event loop is closed when exiting QueueIterator
import asyncio
import aio_pika
async def main(loop):
connection = await aio_pika.connect_robust("amqp://guest:guest@127.0.0.1/", loop=loop)
queue_name = "test_queue2"
# Creating channel