Skip to content

Instantly share code, notes, and snippets.

@jirivrany
jirivrany / pytest_flask_fixtures.py
Created Feb 6, 2018 — forked from qodot/pytest_flask_fixtures.py
Pytest Fixtures (Flask, SQLAlchemy, Alembic)
View pytest_flask_fixtures.py
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
jirivrany / supervisord.service
Last active Apr 6, 2017 — forked from mozillazg/supervisord.service
install and configure supervisord on centos 7.
View supervisord.service
[Unit]
Description=supervisord - Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target
[Service]
Type=forking
ExecStart=/bin/supervisord -c /etc/supervisord/supervisord.conf
ExecReload=/bin/supervisorctl reload
ExecStop=/bin/supervisorctl shutdown
@jirivrany
jirivrany / PhotoAdapter.java
Created Jan 10, 2016
Example of undo action for Android RecyclerView onSwipe.
View PhotoAdapter.java
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
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
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
jirivrany / index.html
Created Dec 10, 2013
JQuery enhance links with class by file type
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
a {
color: orange;
}
@jirivrany
jirivrany / gist:4473639
Created Jan 7, 2013
QDoubleValidator seems to ignore range settings. This seems to be a working solution. Original here: http://learnwithhelvin.blogspot.cz/2010/01/qdoublevalidator.html
View gist:4473639
from PyQt4.QtGui import QDoubleValidator, QValidator
from sys import float_info
class MyDoubleValidator(QDoubleValidator):
'''
Fix for strange behavior of default QDoubleValidator
'''