Skip to content

Instantly share code, notes, and snippets.

View ConvertUnicodeToUTF8
CStringA ConvertUnicodeToUTF8(const CStringW& uni)
{
if (uni.IsEmpty()) return ""; // nothing to do
CStringA utf8;
int cc = 0;
// get length (cc) of the new multibyte string excluding the \0 terminator first
if ((cc = WideCharToMultiByte(CP_UTF8, 0, uni, -1, NULL, 0, 0, 0) - 1) > 0)
{
@charlie-x
charlie-x / gist:33cdd141434a5526d49742418c1a1940
Created Apr 15, 2020
timur spin lock without RAII unlock non realtimesafe/overhead
View gist:33cdd141434a5526d49742418c1a1940
#include <array>
#include <thread>
#include <atomic>
#include <emmintrin.h>
struct spin_mutex {
void lock() noexcept {
// approx. 5x5 ns (= 25 ns), 10x40 ns (= 400 ns), and 3000x350 ns
// (~ 1 ms), respectively, when measured on a 2.9 GHz Intel i9
constexpr std::array iterations = {5, 10, 3000};
@charlie-x
charlie-x / gist:f9d8b0f25cc1c7612cc58ab29901e9ec
Created Nov 1, 2019
install tesla win10 64 bit via powershell
View gist:f9d8b0f25cc1c7612cc58ab29901e9ec
$Path = $env:TEMP; $Installer = "426.23-tesla-desktop-win10-64bit-international.exe"; Invoke-WebRequest "http://us.download.nvidia.com/tesla/426.23/426.23-tesla-desktop-win10-64bit-international.exe" -OutFile $Path\$Installer; Start-Process -FilePath $Path\$Installer -Args "" -Verb RunAs -Wait; Remove-Item $Path\$Installer
View gist:b9c0e316154bd03d453ba89d1ae3f4a2
$Path = $env:TEMP; $Installer = "chrome_installer.exe"; Invoke-WebRequest "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" -OutFile $Path\$Installer; Start-Process -FilePath $Path\$Installer -Args "/silent /install" -Verb RunAs -Wait; Remove-Item $Path\$Installer
View gist:aba3728313d3da66565e027e048dce1e
{NOTE_D5, 600, 50},
{NOTE_E5, 600, 50},
{NOTE_G5, 150, 50},
{NOTE_REST, 100, 50},
{NOTE_G5, 150, 50},
{NOTE_REST, 100, 50},
{NOTE_G5, 150, 50},
@charlie-x
charlie-x / gist:e660af069777b0dfbcaf980e9b7f5501
Created Sep 26, 2018
building openssl1.1.0 windows x64
View gist:e660af069777b0dfbcaf980e9b7f5501
add rc.exe to path, windows sdk etc, default C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x64
add nasm.exe https://www.nasm.us/pub/nasm/releasebuilds/2.13.03/win64/ default C:\Program Files\NASM
vcvars64.bat from 2017 folder default C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64
# no-shared for static libs
# inside openssl extracted source folder
perl configure VC-WIN64A --openssldir=C:\OpenSSL-Win64 no-asm no-shared
View gist:c4e8b4f0eac3e4b590cd3c1472a6ad50
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
rem choco install visualstudio2013professional %1 -y
choco install visualstudio2015professional %1 -y
choco install teamviewer9 %1 -y
chocolatey install paint.net %1 -y
chocolatey install tortoisegit %1 -y
chocolatey install tortoisesvn %1 -y
chocolatey install autodesk-fusion360 %1 -y
chocolatey install f.lux %1 -y
chocolatey install sysinternals %1 -y
@charlie-x
charlie-x / layout.kbd.json
Last active Sep 7, 2017
Untitled Keyboard Layout
View layout.kbd.json
[
{
"backcolor": "#000000",
"switchMount": "cherry",
"switchBrand": "cherry",
"switchType": "MX3A-11Nx",
"pcb": true
},
[
{
View gist:800786d32b2d46362035
### Keybase proof
I hereby claim:
* I am charlie-x on github.
* I am charliex (https://keybase.io/charliex) on keybase.
* I have a public key whose fingerprint is FE99 5AE5 E4B0 E180 D3D2 7D6D F82C 093B EDD7 5A23
To claim this, I am signing this object: