Skip to content

Instantly share code, notes, and snippets.

View webmaster128's full-sized avatar

Simon Warta webmaster128

View GitHub Profile
@webmaster128
webmaster128 / gist:7979803
Created December 15, 2013 23:25
Reproduce CheckBox bug
import QtQuick 2.2
import QtQuick.Controls 1.1
Rectangle {
id: root
color: "silver"
height: 150
width: 200
Timer {
QString f = "download.png";
qDebug() << "Filename: f=" << f;
QUrl u = QUrl(f);
QUrl ulf = QUrl::fromLocalFile(f);
qDebug() << "u = QUrl(f) =" << u << " => " << u.toLocalFile();
qDebug() << "ulf = QUrl::fromLocalFile(f) =" << ulf << " => " << ulf.toLocalFile();
@webmaster128
webmaster128 / copy-qstring-to-qurl-trap.cpp
Created January 4, 2014 15:42
The sample code shows how dangerous it can be to blindly copy a QString to a QUrl. Tested with Qt 5.1.1 and Qt 5.2.0 on Ubuntu.
QUrl dst;
QUrl src = QUrl::fromLocalFile("aPictureFile.jpg");
qDebug() << "INITIAL STATE";
qDebug() << "Source: " << src;
qDebug() << "Destination URL: " << dst;
dst = src;
qDebug() << "END STATE 1";
qDebug() << "Destination URL: " << dst;
qDebug() << "Destination local file: " << dst.toLocalFile();
dst = src.toLocalFile();
@webmaster128
webmaster128 / pullall.sh
Last active January 3, 2016 07:09
A script to pull all git repositories in sub directories.
#!/usr/bin/env python3
import threading
import glob
import os.path
import time
class myThread (threading.Thread):
def __init__(self, threadID, name, repo):
threading.Thread.__init__(self)
self.threadID = threadID
@webmaster128
webmaster128 / hkdf-expander
Last active August 29, 2015 13:58
Command line HKDF expander
#!/usr/bin/env python
'''
Requirements
------------
* Install [hkdf](https://github.com/webmaster128/python-hkdf) globally.
sudo python setup.py install
* Copy file `hkdf-expander` to /usr/local/bin
* Make `/usr/local/bin/hkdf-expander` executable
sudo chmod +x /usr/local/bin/hkdf-expander
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
Rectangle {
width: 400
height: 400
GridLayout {
anchors.fill: parent
@webmaster128
webmaster128 / test.sh
Created October 30, 2014 21:08
Bash version compare operator test
#!/bin/bash
echo "Test 1: '<'"
if [[ 13.10 < 14.04 ]]; then echo "ok"; else echo "fail"; fi;
if [[ 13.10 < 14.04.1 ]]; then echo "ok"; else echo "fail"; fi;
echo
echo "Test 2: '-lt'"
if [[ 13.10 -lt 14.04 ]]; then echo "ok"; else echo "fail"; fi;
if [[ 13.10 -lt 14.04.1 ]]; then echo "ok"; else echo "fail"; fi;
@webmaster128
webmaster128 / librarylogger.h
Last active August 29, 2015 14:08
Cpp logging API
#ifndef LIBRARYLOGGER_H
#define LIBRARYLOGGER_H
#include <iostream>
#include <memory>
#include <cassert>
#ifndef Log
#define Log LibraryLogger(__FILE__, __LINE__, __PRETTY_FUNCTION__)
#endif
import QtQuick 2.3
import QtQuick.Controls 1.1
import QtQuick.Window 2.1
ApplicationWindow {
visible: true
width: 300
height: 300
title: qsTr("Hello World")
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Window 2.2
ApplicationWindow {
title: qsTr("Hello World")
width: 300
height: 300