Skip to content

Instantly share code, notes, and snippets.

@jirivrany
jirivrany / gist:8704099
Created January 30, 2014 07:27
Python - speed comparison of dictionary filling
from collections import defaultdict
def defdic(words):
freq = defaultdict(int)
for word in words:
freq[word] += 1
return dict(freq)
@jirivrany
jirivrany / Hash
Last active August 29, 2015 13:56
Python - map vs. list generator
'''
@author: Jiri Vrany
'''
import hashlib
def hash_word(word):
'''
returns sha512 hash
'''
# -*- 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)
.
├── actions
├── stores
├── views
│   ├── Anonymous
│   │   ├── __tests__
│   │   ├── views
│   │   │   ├── Home
│   │   │   │   ├── __tests__
│   │   │   │   └── Handler.js
@jirivrany
jirivrany / gist:4473639
Created January 7, 2013 09:24
QDoubleValidator seems to ignore range settings. This seems to be a working solution. Original here: http://learnwithhelvin.blogspot.cz/2010/01/qdoublevalidator.html
from PyQt4.QtGui import QDoubleValidator, QValidator
from sys import float_info
class MyDoubleValidator(QDoubleValidator):
'''
Fix for strange behavior of default QDoubleValidator
'''
@jirivrany
jirivrany / index.html
Created December 10, 2013 11:05
JQuery enhance links with class by file type
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
a {
color: orange;
}
@jirivrany
jirivrany / supervisord.service
Last active April 6, 2017 08:03 — forked from mozillazg/supervisord.service
install and configure supervisord on centos 7.
[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 January 10, 2016 20:22
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) {
@jirivrany
jirivrany / pytest_flask_fixtures.py
Created February 6, 2018 14:23 — forked from qodot/pytest_flask_fixtures.py
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