Skip to content

Instantly share code, notes, and snippets.

View pbanaszkiewicz's full-sized avatar

Piotr Banaszkiewicz pbanaszkiewicz

View GitHub Profile
def get_db():
ctx = _app_ctx_stack.top
con = getattr(ctx, "sa_database", None)
if con is None:
con = SQLAlchemy(ctx.app)
ctx.sa_database = con
return con
@pbanaszkiewicz
pbanaszkiewicz / gsoc_visa_exchange.py
Last active October 9, 2015 12:38
Quickly look up conversion rates (GSOC, VISA, PLN, USD, 3% bank fee)
#!/usr/bin/env python
import requests
from datetime import date
import re
def main():
url1 = "http://corporate.visa.com/pd/consumer_services/consumer_ex_rates.jsp"
url2 = "http://corporate.visa.com/pd/consumer_services/consumer_ex_results.jsp"
@pbanaszkiewicz
pbanaszkiewicz / turn_off.py
Created October 13, 2012 11:26
Turn the computer off after specified time. Show notifications.
#!/usr/bin/env python
# coding: utf-8
import os
import datetime
import time
import pynotify
MAX_UPTIME = 60 * 60 # in seconds: 1 hour
@pbanaszkiewicz
pbanaszkiewicz / gist:5178702
Last active December 15, 2015 01:18
Swearing sudo
$ sudo /bin/false
[sudo] password for piotr:
There must be cure for it!
[sudo] password for piotr:
And with that remarks folks, the case of the Crown vs yourself was proven.
[sudo] password for piotr:
Where did you learn to type?
sudo: 3 błędne próby wprowadzenia hasła
@pbanaszkiewicz
pbanaszkiewicz / MIGRATIONS_README.rst
Last active December 19, 2015 11:48
Managing migrations for Ganeti Web Manager

MIGRATIONS

During Ganeti Web Manager refactoring one huge application (ganeti_web) was turned into many smaller applications (actual list: authentication, clusters, django_test_tools, ganeti_web, jobs, muddle, muddle_users, nodes, utils, virtualmachines, vm_templates).

However, over 19 migrations are still placed in ganeti_web application. How to make them work? My idea is as follows:

@pbanaszkiewicz
pbanaszkiewicz / install.rst
Last active December 21, 2015 00:59
Ganeti Web Manager ``setup.sh`` installation script

Ganeti Web Manager installation

(You can watch the progress here.)

Proposed setup.sh installation script for GWM would:

  1. detect user's operating system (Debian or CentOS)
  2. install system dependencies (Python, python-virtualenv) via user's OS default package managers (apt or yum) [this will require sudo]
  3. create virtual environment in local directory (or in directory specified by user)
@pbanaszkiewicz
pbanaszkiewicz / gist:6317667
Created August 23, 2013 10:07
Helpful resources to learn vim (some in Polish)
@pbanaszkiewicz
pbanaszkiewicz / gist:6346284
Last active December 21, 2015 18:19
GWM GSOC 2013 TODO
  • python setup.py test (is it necessary now if we reject Travis-CI?)
  • getopts in setup.sh
  • using Vagrant to set up & compile wheel dependencies of GWM (at least provide some shell script to do it, Vagrantfiles aren't necessary)
  • installing dependencies & ganeti_webmgr from OSUOSL FTP mirrors
  • --upgrade option for setup.sh (or something clever like recognizing existing virtual environments)
  • GWM tools package & default configuration
@pbanaszkiewicz
pbanaszkiewicz / Preferences.sublime-settings
Last active December 27, 2021 16:53
Sublime Text 3 configuration
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"caret_style": "solid",
"color_scheme": "Packages/Monokai Extended/Monokai Extended.tmTheme",
"draw_minimap_border": true,
"enable_telemetry": false,
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
[
@pbanaszkiewicz
pbanaszkiewicz / os.sh
Last active December 21, 2015 21:29
Detect Linux operating system distribution, it's version and architecture (only Ubuntu, Debian and CentOS).
lsb_release='/usr/bin/lsb_release'
architecture=`uname -i`
os='unknown'
if [ -x $lsb_release ]; then
# we pull in default values, should work for both Debian and Ubuntu
os=`$lsb_release -s -i | tr "[:upper:]" "[:lower:]"`
if [ "$OS" == "centos" ]; then
os_codename=`$lsb_release -s -r | sed -e 's/\..*//'`