Skip to content

Instantly share code, notes, and snippets.

View SC-One's full-sized avatar
👥
Missing

Heydar Mahmoodi SC-One

👥
Missing
View GitHub Profile
@SC-One
SC-One / CMakeLists.txt
Created May 31, 2024 21:06 — forked from baiwfg2/CMakeLists.txt
How to use add_custom_target and add_custom_command correctly in cmake
# References:
# https://cmake.org/cmake/help/latest/command/add_custom_target.html
# https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/
# https://gist.github.com/socantre/7ee63133a0a3a08f3990
# https://stackoverflow.com/questions/24163778/how-to-add-custom-target-that-depends-on-make-install
# https://stackoverflow.com/questions/30719275/add-custom-command-is-not-generating-a-target
# https://stackoverflow.com/questions/26024235/how-to-call-a-cmake-function-from-add-custom-target-command
# https://blog.csdn.net/gubenpeiyuan/article/details/51096777
cmake_minimum_required(VERSION 3.10)
@SC-One
SC-One / QtMinorVersionsCheck.cmake
Last active February 19, 2024 22:49
CMake code for checking qt major minor patch version
# First way todays:
find_package(QT 5.15.2 NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick LinguistTools)
############################################################################################
# Alternative way:
if (Qt5Core_FOUND)
if (Qt5Core_VERSION VERSION_LESS 5.15.2)
message(FATAL_ERROR "Minimum supported Qt5 version is 5.15.2! current version: " ${Qt5Core_VERSION})
endif()
@SC-One
SC-One / generate-icns.sh
Created December 18, 2023 16:09 — forked from ahmed-musallam/generate-icns.sh
A Shell script to generate .ico and .icns files (mac/windows app icons) from a single PNG
# Required deps:
# imagemagick: https://imagemagick.org/script/download.php
# name of your master icon, must be at least 512X512
PNG_MASTER="icon-large.png"
ICONSET_FOLDER="AppIcon.iconset"
sizes=(
16x16
32x32
@SC-One
SC-One / CircularBuffer.qml
Last active October 2, 2023 18:53
implementation of CircularBuffer in qml
import QtQuick 2.0
QtObject {
property int maximumSize: 10
property var buffer: []
property int head: 0
property int size: 0
function initialize() {
buffer = [];
@SC-One
SC-One / 01-mac-profiling.md
Created September 4, 2023 09:41 — forked from loderunner/01-mac-profiling.md
Profiling an application in Mac OS X

Profiling an application in Mac OS X

Finding which process to profile

If your system is running slowly, perhaps a process is using too much CPU time and won't let other processes run smoothly. To find out which processes are taking up a lot of CPU time, you can use Apple's Activity Monitor.

The CPU pane shows how processes are affecting CPU (processor) activity:

@SC-One
SC-One / FooTableModel.h
Created May 17, 2023 14:02
How subclassing QAbstractTableModel in qt
class FooTableModel : public QAbstractTableModel {
Q_OBJECT
public:
FooTableModel(QObject *parent = nullptr);
// readonly tables
Qt::ItemFlags flags(const QModelIndex &index)
const override; // editable can return: Qt::ItemIsEditable
QVariant data(const QModelIndex &index,
int role = Qt::DisplayRole) const override;
@SC-One
SC-One / cuda_11.7_installation_on_Ubuntu_22.04
Created April 8, 2023 08:18 — forked from primus852/cuda_11.7_installation_on_Ubuntu_22.04
Instructions for CUDA v11.7 and cuDNN 8.5 installation on Ubuntu 22.04 for PyTorch 1.12.1
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check
@SC-One
SC-One / install_cuda_11_ubuntu_2004.md
Created April 7, 2023 19:42 — forked from ksopyla/install_cuda_11_ubuntu_2004.md
How to install CUDA toolkit 11 at ubuntu 20.04

Step by step instruction how to install CUDA 11 Ubuntu 20.04

NVidia Ubuntu 20.04 repository for CUDA 11

If you need CUDA Tolkit 11 with nvcc, other tools and libraries you can install it from NVIDIA Ubunutu 20.04 repository.

Add Ubuntu 20.04 repository

@SC-One
SC-One / bash_aliases
Created March 15, 2023 06:31
My favorite aliases in bash (usefull in ubuntu's terminal)
alias gitstart='eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
'
alias copy='xclip -selection clipboard'
# alias bjson='python -m json.tool' # beautify json
bjsonStr(){
echo "$1" | python3 -m json.tool
}
bjsonFile(){
python3 -m json.tool "$1"
@SC-One
SC-One / CustomProgressBar.qml
Last active March 1, 2023 06:38
simple sample of CustomProgressbar in QML (QtQuick2)
import QtQuick 2.15
Rectangle {
id:rootRect
property int currentValue:0;
property int maxValue:100;
property int minValue:0;
property color colorBar:"#7ec26e";
property alias textBar: barText