Skip to content

Instantly share code, notes, and snippets.

jirivrany /
Created Feb 6, 2018 — forked from qodot/
Pytest Fixtures (Flask, SQLAlchemy, Alembic)
import sys
import pytest
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from alembic.command import upgrade as alembic_upgrade
from alembic.config import Config as AlembicConfig
from wsgi import create_app
from config import config
jirivrany / supervisord.service
Last active Apr 6, 2017 — forked from mozillazg/supervisord.service
install and configure supervisord on centos 7.
View supervisord.service
Description=supervisord - Supervisor process control system for UNIX
ExecStart=/bin/supervisord -c /etc/supervisord/supervisord.conf
ExecReload=/bin/supervisorctl reload
ExecStop=/bin/supervisorctl shutdown
jirivrany /
Created Jan 10, 2016
Example of undo action for Android RecyclerView onSwipe.
public class PhotoAdapter extends RecyclerView.Adapter<PhotoAdapter.PhotoViewHolder> implements View.OnClickListener {
private ArrayList<Photo> photos;
public ArrayList<Photo> photosToRemove;
private OnItemClickListener onItemClickListener;
private Context context;
public PhotoAdapter(Context context, ArrayList<Photo> photos, Map<Integer, String> authors, int colHeigth) {
View react-app-file-structure
├── actions
├── stores
├── views
│   ├── Anonymous
│   │   ├── __tests__
│   │   ├── views
│   │   │   ├── Home
│   │   │   │   ├── __tests__
│   │   │   │   └── Handler.js
View gist:77d4f250f773e81064dc
# -*- coding: UTF-8 -*-
Parsovani velkych soubory pomoci Eltree iter parseru
import xml.etree.ElementTree as etree
import bz2
def fix_tag(ns, nsmap, tag):
return '{{{}}}{}'.format(nsmap[''], tag)
jirivrany / Hash
Last active Aug 29, 2015
Python - map vs. list generator
View Hash
@author: Jiri Vrany
import hashlib
def hash_word(word):
returns sha512 hash
jirivrany / gist:8704099
Created Jan 30, 2014
Python - speed comparison of dictionary filling
View gist:8704099
from collections import defaultdict
def defdic(words):
freq = defaultdict(int)
for word in words:
freq[word] += 1
return dict(freq)
jirivrany / index.html
Created Dec 10, 2013
JQuery enhance links with class by file type
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<style type="text/css">
a {
color: orange;
jirivrany / gist:4473639
Created Jan 7, 2013
QDoubleValidator seems to ignore range settings. This seems to be a working solution. Original here:
View gist:4473639
from PyQt4.QtGui import QDoubleValidator, QValidator
from sys import float_info
class MyDoubleValidator(QDoubleValidator):
Fix for strange behavior of default QDoubleValidator