Skip to content

Instantly share code, notes, and snippets.

View blakebjorn's full-sized avatar

Blake Anderson blakebjorn

View GitHub Profile
@blakebjorn
blakebjorn / table.py
Created May 6, 2020 16:52
QTableView Example
import sys
import random
from PySide2 import QtCore, QtWidgets
class TableModel(QtCore.QAbstractTableModel):
def __init__(self, parent=None, data=None, columns=None, *args):
QtCore.QAbstractTableModel.__init__(self, parent, *args)
self.dataset = data
self.columns = columns
@blakebjorn
blakebjorn / app.py
Created June 18, 2019 12:37
Example communication between flask application and python worker using zeroMQ
import zmq
from flask import Flask
from threading import Thread
HOST = '127.0.0.1'
PORT = 9090
TASK_SOCKET = zmq.Context().socket(zmq.REQ)
TASK_SOCKET.connect('tcp://{}:{}'.format(HOST, PORT))
app = Flask("app")
@blakebjorn
blakebjorn / jinjaExample.py
Created March 9, 2018 15:38
pdf generation with jinja2 and html
import pandas as pd
import jinja2
import pdfkit
from random import getrandbits, randint
# pdfkit is just a wrapper for whktmltopdf. you need to install wkhtml and have it on the path
# alternatively, you can move wkhtmltoimage.exe, wkhtmltopdf.exe and wkhtmltox.dll into the working directory
# Create some data
def random_hex(length=10):
import time
import traceback
import sys
class NumberFactory(object):
def __init__(self, starting_value):
self.value = starting_value
def increment(self):
self.value += 1
@blakebjorn
blakebjorn / pyqt threading example.py
Created December 12, 2016 00:13
PySide/PyQT non-blocking thread example
from PySide import QtCore, QtGui
import sys
import time
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
#Build a UI
self.myLayout = QtGui.QVBoxLayout()
self.myCentralWidget = QtGui.QWidget()
@blakebjorn
blakebjorn / bitfinexTicker.sh
Created July 5, 2016 16:41
Bash script, returns bitfinex ticker (mid) rounded to two decimal places. I use this for desktop notifications in xfce using genmon.
#!/bin/bash
printf "%.2f" $(curl -s -H "Accept: application/json" -H "Content-Type: application/json" https://api.bitfinex.com/v1/pubticker/btcusd | grep -Po '(?<="mid":")[^"]*')
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 17 11:45:45 2016
@author: Blake Anderson
"""
from PySide import QtGui
from PySide import QtCore
import requests