Skip to content

Instantly share code, notes, and snippets.

@kovrov
kovrov / SwipeArea.qml
Last active August 16, 2023 14:50
Swipe
/* This code was written by Sergejs Kovrovs and has been placed in the public domain. */
import QtQuick 2.0
MouseArea {
property point origin
property bool ready: false
signal move(int x, int y)
signal swipe(string direction)
@kovrov
kovrov / list.qml
Created January 4, 2012 16:05
File selector in QML and PySide (http://blogs.kde.org/node/4437)
import QtQuick 1.0
import Self 1.0
Rectangle {
id: page
width: 400; height: 240;
anchors.fill: parent
DirModel {
id: dirModel
@kovrov
kovrov / imap_search.py
Created November 16, 2011 23:22
imaplib search example
import getpass, imaplib
from itertools import islice
from email.parser import HeaderParser
def number_set(seq):
res = []
last = first = next(seq)
for i in seq:
assert last < i
if i - last == 1:
// g++ gl3.cpp -o gl3 -lX11 -lGL
#include <GL/glx.h>
#include <GL/gl.h>
#include <iostream>
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
typedef GLXContext (glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
@kovrov
kovrov / main.c
Created October 13, 2011 13:20
Mac OS X Lion OpenGL Core Profile (CGLChoosePixelFormat)
/* gcc -framework OpenGL main.c */
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl3.h>
#include <stdio.h>
int main(int argc, char **argv)
{
CGLContextObj ctx;
CGLPixelFormatObj pix;
varying vec2 screenPos;
varying float radius;
uniform sampler2D tex;
void main()
{
float dist_squared = distance(gl_FragCoord.xy, screenPos);
// Sphere shaded
if (dist_squared > radius)
struct Point { float x, y; }
Point[] triangulate(const ref Point[] contour)
{
assert (contour.length > 2);
Point[] result;
scope size_t[] V; // TODO: V.reserve(contour.length)
def isFirstCodepoint(b):
return 0b10000000 & b == 0 or 0b11000000 & b != 0b10000000
def splitUtf8(arr, i):
if isFirstCodepoint(arr[i]):
return arr[:i], arr[i:]
while i > 0:
i -= 1
if isFirstCodepoint(arr[i]):
break;
@kovrov
kovrov / qmailthreadmodel.h
Created July 21, 2011 13:53
QMF query threads
QMailStore *store = QMailStore::instance();
QMailAccountIdList accounts = store->queryAccounts();
QMailAccount account = QMailAccount(accounts[0]);
QMailFolderId folder_id = account.standardFolder(QMailFolder::InboxFolder);
QMailMessageKey folder_key = QMailMessageKey::parentFolderId(folder_id);
QMailThreadKey select_key = QMailThreadKey::includes(folder_key);
// we can only sort by id or serverUid ?
QMailThreadSortKey sort_key = QMailThreadSortKey::id(Qt::AscendingOrder);
@kovrov
kovrov / config.pro
Created May 31, 2011 14:28
QMF config
TEMPLATE = app
TARGET = config
QT += core
QT -= gui
CONFIG += console
CONFIG -= app_bundle
LIBS += -lqmfclient