Skip to content

Instantly share code, notes, and snippets.

View oclero's full-sized avatar

Olivier Cléro oclero

View GitHub Profile

How to install a NSIS 3 plugin with Powershell

How a NSIS plugin looks like

A NSIS 3.x plugin is most of the time:

  • yourPlugin.nsh: The header to include
  • yourPlugin.dll: The DLL, often built from a C program.

The file structure for plugins, in C:\Program Files (x86)\NSIS, is:

Use Windows' OpenSSH with Git

How to configure Windows 10 built-in OpenSSH for Git. No need for Putty anymore.

  1. Open a Powershell console in Administrator mode.

  2. Install Windows' OpenSSH client.

$OpenSSHClient = Get-WindowsCapability -Online | ? Name -like 'OpenSSH.Client*'

How to use C++ enums with Qt/Qml

Utilisation d'une enum ou enum class dans un QObject

C++

Déclaration de la classe qui hérite de QObject dans les fichiers .cpp/.hpp:

  • Macro Q_OBJECT : déclare le méta-type pour la classe MyObject.
  • Macro Q_ENUM : déclare les infos nécessaires pour l'enum MyEnum.
@oclero
oclero / HowToDrawQQuickRectangle.md
Last active September 2, 2021 12:31
C++ RoundedRectangle for QML usage

How to draw a C++ QtQuick rectangle with different border radius

Theses classes show how to make a QQuickItem that draws a rectangle with different border radiuses /different roundings.

  • RoundedRectangle: the C++ class that draws the rectangle, using QPainter API.
  • RoundedCorners: a C++ class to simplify the definition of different roundings.
RoundedRectangle {
 width: 100
@oclero
oclero / HowToOptimizeSVGWithPowershell.md
Last active September 2, 2021 12:36
How to optimize SVG files with Powershell and scour

How to optimize SVG files with Powershell and scour

  1. Install Python and pip
  2. Install the Python program named scour
    pip install scour
  3. Run this program on files with the example script below.

How to customize Powershell profile

The Powershell profile is stored in the $PROFILE alias which is actually the file C:\Users\$env:USERNAME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1.

notepad $PROFILE

Some examples of what you can add:

How to install WSL2 on Windows

Open Powershell with admin privileges. Be prepared to reboot a lot...

  1. Enable WSL feature.

    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
@oclero
oclero / ResetAnyGitRepositoryChanges.md
Last active September 2, 2021 12:42
Clean any change in a Git repository

How to totally reset local modifications with git

When you have modifications in your Git repository, both in source files and submodules, here is the ultimate solution.

git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
@oclero
oclero / GitInfoInPowershell.md
Last active September 6, 2021 12:35
How to get Git information (branch, commits, etc.) in Powershell prompt

See Git information (branch, commits, etc.) in Powershell prompt

Preliminary step: ensure you can run scripts in Powershell:

Set-ExecutionPolicy Unrestricted

In Powershell console, type:

@oclero
oclero / HowToStylizeQtApplication.md
Last active September 15, 2021 16:01
How to stylize a Qt Application

How to stylize a Qt Application

QWidget and QPainter

What is QWidget?

QWidget is the class that represents a element on the Graphical User interface. It has thus a visual representation on the screen, and receives events regularly to allow it to update its state. It must be re-drawn on the screen each time it receives an event that suggests a modification of its appearance. For instance, a button will repaint itself when it is pressed by the mouse pointer.

How does QWidget draw itself on the screen?