Skip to content

Instantly share code, notes, and snippets.

@j-ulrich
j-ulrich / conanfile.txt
Last active February 11, 2023 16:17
Qbs Conan ModuleProvider
[requires]
poco/1.6.1
yajl/2.1.0
expat/2.2.0
@dismine
dismine / qt.rb
Last active May 2, 2021 15:31
Switch to Qt 5.8.
# Patches for Qt must be at the very least submitted to Qt's Gerrit codereview
# rather than their bug-report Jira. The latter is rarely reviewed by Qt.
class Qt < Formula
desc "Cross-platform application and UI framework"
homepage "https://www.qt.io/"
revision 2
head "https://code.qt.io/qt/qt5.git", :branch => "5.8", :shallow => false
stable do
url "https://download.qt.io/official_releases/qt/5.8/5.8.0/single/qt-everywhere-opensource-src-5.8.0.tar.xz"
@micjabbour
micjabbour / datastream_enum.h
Last active February 24, 2023 11:27
(de)serialize enums into QDataStream
#ifndef DATASTREAM_ENUM_H
#define DATASTREAM_ENUM_H
#include <type_traits>
//a function that can serialize any enum into QDataStream
//it stores the enum in a qint64
template<typename Enum,
typename = typename std::enable_if<std::is_enum<Enum>::value>::type>
@gunjanpatel
gunjanpatel / revert-a-commit.md
Last active May 3, 2024 20:50
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@fffaraz
fffaraz / rand.cpp
Created July 22, 2014 10:51
Random number in Qt
#include <QGlobal.h>
#include <QTime>
int QMyClass::randInt(int low, int high)
{
// Random number between low and high
return qrand() % ((high + 1) - low) + low;
}
// Create seed for the random
@EyalAr
EyalAr / client.py
Created December 11, 2013 18:17
Demo code for my post about python's blocking stream reading functions.
from subprocess import Popen, PIPE
from time import sleep
# run the shell as a subprocess:
p = Popen(['python', 'shell.py'],
stdin = PIPE, stdout = PIPE, stderr = PIPE, shell = False)
# issue command:
p.stdin.write('command\n')
# let the shell output the result:
sleep(0.1)