Skip to content

Instantly share code, notes, and snippets.

@peteristhegreat
peteristhegreat / MainWindowForm.qml
Last active March 14, 2018 14:11
QML console.log qDebug() to QML TextEdit object using qInstallMessageHandler
import QtQuick.Window 2.2
Window {
id: root
Flickable {
id: flick
Layout.minimumHeight: 50
Layout.fillHeight: true
@peteristhegreat
peteristhegreat / git diff sqlite3 .gitattributes
Last active March 25, 2024 12:38
Sqlite git diff - Get git to use an sql dump of sqlite3 for showing differences ( .gitconfig config attributes sqlite3 )
*.db diff=sqlite3
@peteristhegreat
peteristhegreat / PieChart.qml
Last active July 29, 2016 03:38
qt-quick-qml-and-canvas-tutorial pie chart example
// http://www.slideshare.net/emayssat/qt-quick-qml-and-canvas-tutorial
import QtQuick 2.0
Item {
Rectangle {
id: root
width: 640
height: 360
color: "#3C3C3C"
ListModel {
@peteristhegreat
peteristhegreat / getopt_python_example.py
Created August 8, 2016 17:15
getopt python commandline arguments parameters usage verbose help dry-run - all in one example
#!/usr/bin/env python
# This file is intended to be a quick template for making a commandline tool in python using getopt to hande the arguments.
import sys, os, re, getopt
def usage():
# output comparable to argparse
# https://docs.python.org/2/library/argparse.html#module-argparse
filename = os.path.basename(__file__)
@peteristhegreat
peteristhegreat / explode_rows.vba
Last active August 30, 2016 20:54
Excel explode rows split rows based on a column vba script
Sub Main()
Call explode_rows("Sheet1", "Sheet2", 2, ",")
End Sub
Function explode_rows(sheet_src As String, sheet_dest As String, col As Integer, sep As String)
Dim wb As Workbook
Dim r_src As Integer
Dim r_dest As Integer
@peteristhegreat
peteristhegreat / bash_stack_trace.bash
Created November 7, 2016 19:19
Show a back trace in bash with context lines.
# Prints the stack trace and some context lines for where the stack trace happened
# rotate the log
unlink /var/rotating_log.log
datetime=$(date +%m%d%Y_%H%M%S);
logfile="rotating_log_$datetime.log"
echo "Started on $datetime" > $logfile
#chfile mygroup 664 $logfile
ln -s $logfile rotating_log.log
@peteristhegreat
peteristhegreat / sample_d4m.json
Created January 4, 2017 03:55
sample json for decide4me
{
"game_setups": [
{
"name": "setup_template",
"players": [
{
"name": "Player 1"
},
{
"name": "Player 2"
@peteristhegreat
peteristhegreat / main.cpp
Created January 13, 2017 21:21
QHoverEvent in a QPushButton (and leaveEvent and enterEvent)
#include <QApplication>
#include "mypushbutton.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyPushButton pb;
pb.show();
return a.exec();
}
@peteristhegreat
peteristhegreat / readonlydelegate.cpp
Created January 17, 2017 20:59
Read-only QItemDelegate for use with Qt QTableView
#include "readonlydelegate.h"
ReadOnlyDelegate::ReadOnlyDelegate(QObject *parent) :
QItemDelegate(parent)
{
}
bool ReadOnlyDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
{
return false;
@peteristhegreat
peteristhegreat / checkablesortfilterproxymodel.cpp
Created January 17, 2017 21:04
Checkable/Checkbox SQL item in Qt QTableView
#include "checkablesortfilterproxymodel.h"
CheckableSortFilterProxyModel::CheckableSortFilterProxyModel(QObject *parent) :
QSortFilterProxyModel(parent)
{
}
void CheckableSortFilterProxyModel::setParameters(QList<int> boolCols) {
booleanSet.clear();
if (!boolCols.isEmpty()) {