Skip to content

Instantly share code, notes, and snippets.

@kovrov
kovrov / binary-clock.qml
Created March 15, 2014 23:25
Binary clock displaying binary-coded decimals
import QtQuick 2.2
Rectangle {
id: root
width: 360
height: 360
Timer {
id: d
@kovrov
kovrov / qmlsettings.cpp
Created November 20, 2013 19:04
QML Settings
#include "qmlsettings.h"
#include <QtCore/QSettings>
QmlSettings::QmlSettings(QObject *parent) :
QQmlPropertyMap (parent),
m_settings (new QSettings(this))
{
m_settings->beginGroup("qml");
foreach (const auto &key, m_settings->allKeys()) {
@kovrov
kovrov / Pincho.js
Last active December 22, 2015 14:59
Pincho the pinchinator for flickable.
var scale
var flickable
var target
@kovrov
kovrov / Spinner.qml
Last active December 22, 2015 04:59
import QtQuick 2.1
Item {
id: root
property color color
width: 64; height: 64
Canvas {
id: canvas
property point center: Qt.point(width / 2, height / 2)
@kovrov
kovrov / match3.qml
Last active December 12, 2015 06:18
import QtQuick 2.0
Rectangle {
id: board
width: 480
height: 480
color: "black"
Grid {
id: grid
@kovrov
kovrov / bootstrap.pro
Last active January 27, 2017 22:20
QML components bootstrap.
TEMPLATE = lib
QT += declarative
CONFIG += qt plugin
TARGET = $$qtLibraryTarget($$TARGET)
# for qtcreator
uri = com.example.bootstrap
#DESTDIR = $$replace(uri, \\., /)
@kovrov
kovrov / xmlrpc.js
Created August 30, 2012 23:21
xml-rpc qml javascript utils
.pragma library
function parseResponse(xml) {
try {
if (xml.documentElement.firstChild.tagName === 'fault') {
throw new Error("TODO: XML-RPC fault")
}
return _parseValue(_querySelector(xml.documentElement, "params param value"))
}
@kovrov
kovrov / storage.js
Created June 2, 2012 17:46
Simple QML storage wrapper for settings
.pragma library
function Settings(applicationName, applicationVersion) {
this.db = openDatabaseSync(applicationName, applicationVersion)
this.db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS settings(name TEXT UNIQUE, value TEXT)')
})
}
int64_t pow_r(int64_t a, int64_t b)
{
if (b == 0)
return 1;
if (b == 1)
return a;
int64_t res = pow_r(a, b/2);
res *= res;
#include <algorithm> // iter_swap
#include <vector>
#include <assert.h>
using namespace std;
template<typename IT>
bool is_sorted(IT begin, IT end)
{