Skip to content

Instantly share code, notes, and snippets.

View ksvbka's full-sized avatar
💭
CFF - Code for food 👍

Trung Kien ksvbka

💭
CFF - Code for food 👍
View GitHub Profile
@ksvbka
ksvbka / Build-step.sh
Last active February 19, 2020 01:34
Two views onto the same model. TODO: implement selection model
qmake -project
# Add option by edit *.pro
# QT += core gui widgets
qmake
make
@ksvbka
ksvbka / pyqt-qsettings.py
Last active September 13, 2019 06:58
pyqt5: QSettings demo
#! /usr/bin/python3
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtCore import QCoreApplication, QSettings
class Window(QMainWindow):
def __init__(self):
super(Window, self).__init__()
settings = QSettings()
self.list = settings.value('list', ['a', 'b', 'c'])
@ksvbka
ksvbka / stl_algorithm_demo.cpp
Last active July 31, 2021 02:01
Demo algorithm in STL
#include <vector>
#include <utility> // std::pair
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[])
{
@ksvbka
ksvbka / inet_sockets.c
Created April 2, 2019 03:20
Socket util
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@ksvbka
ksvbka / log_pipe.py
Last active January 5, 2019 02:42
redirect linux cmd to logfile or print to screen
import os
import uuid
import threading
import logging
import subprocess
class LogPipe(threading.Thread):
def __init__(self, logfile=None, level=logging.INFO):
"""Setup the object with a logger and a loglevel and start the thread
@ksvbka
ksvbka / worker-threadpool.py
Created December 19, 2018 15:29
Demo worker threadpool and report progress in PyQT.
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QVBoxLayout, QPushButton, QWidget
from PyQt5.QtCore import QObject, QRunnable, QThreadPool,pyqtSlot, pyqtSignal
import time
import traceback, sys
class WorkerSignals(QObject):
'''
Defines the signals available from a running worker thread.
Supported signals are:
@ksvbka
ksvbka / widgets_example.py
Last active July 17, 2019 15:34
Sample example contain all common widgets of PyQT5. Ref link https://build-system.fman.io/pyqt5-tutorial
#!/usr/bin/env python3
from PyQt5.QtCore import QDateTime, Qt, QTimer
from PyQt5.QtWidgets import (QApplication, QCheckBox, QComboBox, QDateTimeEdit,
QDial, QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
QProgressBar, QPushButton, QRadioButton, QScrollBar, QSizePolicy,
QSlider, QSpinBox, QStyleFactory, QTableWidget, QTabWidget, QTextEdit,
QVBoxLayout, QWidget)
@ksvbka
ksvbka / debian.gitignore
Created August 6, 2018 02:21
Debian gitignore
# Ignore generated files
/*.deb
/*.dsc
/*.changes
# Only care about debian/ directory
/*/*
!/*/debian
# Ignore files generated during build
@ksvbka
ksvbka / appindicator.py
Created May 4, 2018 06:48
App Indicator demo. Create icon in systemtray. Work with both GTK and KDE
#!/usr/bin/python3
import signal
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')
from gi.repository import Gtk
from gi.repository import AppIndicator3 as AppIndicator
@ksvbka
ksvbka / bobp-python.md
Created April 11, 2018 15:11 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens