Skip to content

Instantly share code, notes, and snippets.

View oclero's full-sized avatar

Olivier Cléro oclero

View GitHub Profile

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*'
@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:

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:

How to setup an SSH server on Windows 10

Install on Windows machine

In an Administrator Powershell terminal, type:

$OpenSSHServer = Get-WindowsCapability -Online | ? Name -like 'OpenSSH.Server*'
Add-WindowsCapability -Online -Name $OpenSSHServer.Name
Start-Service sshd
@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

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

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.

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:

@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?

@oclero
oclero / HowToDrawQmlRectangle.md
Last active April 9, 2022 19:02
Draws a Rectangle with different border radiuses

How to draw a QML rectangle with different border radius

There are two ways of drawing a rectangle with different border radiuses / different roundings in pure QML:

  1. Using the Canvas QML API, which is similar to using QPainter in C++ and the Canvas web API in JavaScript (CPU-based).
  2. Using Shape QML API, which has a declarative paradigm, and better performance because it can directly draw with GPU, if your platform supports GL_NV_path_rendering.