Skip to content

Instantly share code, notes, and snippets.

View lukassup's full-sized avatar
🍕

Lukas Šupienis lukassup

🍕
View GitHub Profile
#!/bin/bash
random_choice() {
choices=("$@")
echo ${choices[$(( $RANDOM % ${#choices[@]} ))]}
}
random_choice "$@"
import logging
import time
from functools import wraps
from itertools import chain, starmap
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)
version: '2'
services:
# mq:
# image: rabbitmq:3.6
# expose:
# - '5672'
db:
image: postgres:9.5
environment:
- POSTGRES_PASSWORD=postgres

SQLite3 CSV import tutorial

Start up the sqlite3 shell. I am going to use fps.db as my database file:

$ sqlite3 fps.db
SQLite version 3.14.2 2016-09-12 18:50:49
Enter ".help" for usage hints.
sqlite> 
" vim: set sw=2 ts=2 sts=2:
"
if !has("nvim")
set nocompatible
endif
call plug#begin('~/.vim/plugged')
Plug 'morhetz/gruvbox'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-surround'

BTRFS

$ mount | grep btrfs
/dev/mapper/vg-system on / type btrfs (rw,relatime,compress=lzo,ssd,space_cache,subvolid=260,subvol=/root)
/dev/mapper/vg-system on /home type btrfs (rw,relatime,compress=lzo,ssd,space_cache,subvolid=261,subvol=/home)
/dev/mapper/vg-system on /var/lib/docker/btrfs type btrfs (rw,relatime,compress=lzo,ssd,space_cache,subvolid=260,subvol=/root/var/lib/docker/btrfs)
" vim: set sw=2 ts=2 sts=2:
"
if !has('nvim')
set nocompatible
endif
call plug#begin('~/.vim/plugged')
Plug 'morhetz/gruvbox'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-surround'
root@twopi ~log/remote/router.isp # grep -r '\bMissed\b' . | wc -l
350
root@twopi ~log/remote/router.isp # ls | wc -l
85
root@twopi ~log/remote/router.isp # python
Python 3.5.2 (default, Jul 3 2016, 09:10:18)
[GCC 6.1.1 20160602] on linux
Type "help", "copyright", "credits" or "license" for more information.

Creating an RPM from a Python package

On your dev host you need Python, virtualenv and Docker installed.

On your build host (or container) you need python and rpm-build packages.

Install cookiecutter Python package in your Python virtualenv. It can be used to create instalable Python packages. Most importantly, it creates the setup.py file for you.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import requests
try:
from lxml.etree import ElementTree as ET, Element as E
except ImportError: