Skip to content

Instantly share code, notes, and snippets.

void decrypt(short* src, short* dest, int size)
{
int x=0xA2C2A, y=0;
for (int i = 0; i < size; ++i)
{
x = x*0x343FD + 0x269EC3;
y = x >> 0x10 & 0x7FFF;
dest[i] = src[i] ^ LOWORD(y);
}
}
@Trass3r
Trass3r / PurgeRAM.cpp
Last active March 21, 2017 15:14
Purge physical RAM
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static bool PurgeRAM()
{
MEMORYSTATUSEX info = {};
info.dwLength = sizeof(MEMORYSTATUSEX);
if (!GlobalMemoryStatusEx(&info))
return false;
@Trass3r
Trass3r / EnableVisualStudioProjectRebuildReasonLogging.reg
Created November 17, 2016 15:23
Get Visual Studio logging for 'fast up-to-date checker'
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\General]
"U2DCheckVerbosity"=dword:00000001
@Trass3r
Trass3r / clangoptions.props
Last active February 20, 2018 17:15
MSBuild specify parameters on the commandline
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<TreatWarningAsError>false</TreatWarningAsError>
<!-- otherwise in fallback mode you might end up with /Zi object files -->
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<OpenMPSupport>true</OpenMPSupport>
<!-- -fuse-ld=lld -->
@Trass3r
Trass3r / CheckProjectFileHeadersExist.cs
Last active January 12, 2017 18:02
check vcxproj files for non-existent header files causing MSBuild to rebuild
using System;
using System.IO;
using System.Xml.Linq;
static class Program
{
static void check(string fileName)
{
XDocument project = XDocument.Load(fileName);
XNamespace msbuild = XNamespace.Get("http://schemas.microsoft.com/developer/msbuild/2003");
@Trass3r
Trass3r / VLDSnippet.cpp
Created January 18, 2017 12:48
quick and dirty VLD enable
#pragma comment(lib, "D:\\Visual Leak Detector\\lib\\Win64\\vld.lib")
#include <D:\Visual Leak Detector\include\vld.h>
static int dummy = (VLDSetReportOptions(VLD_OPT_REPORT_TO_FILE | VLD_OPT_UNICODE_REPORT, nullptr), 0);
@Trass3r
Trass3r / dl.py
Created February 4, 2017 13:08
download aerial imagery from Geoportal TH
import requests
from urllib.request import *
import sys
import os.path
def getDetails(type, id):
url = 'http://geoportal.geoportal-th.de/gaialight-th/_apps/dladownload/_ajax/details.php'
params = dict(
type = type,
id = id
@Trass3r
Trass3r / threadnaming.h
Last active June 5, 2019 14:47
SetThreadName for Windows/Linux
// https://godbolt.org/z/5Fyg7y
#pragma once
#include <stddef.h>
#include <stdint.h>
#if _WIN32
#define WIN32_LEAN_AND_MEAN
@Trass3r
Trass3r / auto-vectorization-flags.sh
Last active November 6, 2018 08:59
auto-vectorization report compiler flags
# useful to test auto-vectorization on different compilers
# https://godbolt.org/z/mUdeQn
# gcc
-Wall -W -std=c++2a -fopenmp-simd -O3 -ffast-math -march=haswell -fopt-info-vec-omp-optimized-missed
# clang
-Wall -W -Werror=pass-failed -std=c++2a -fopenmp-simd -O3 -ffast-math -march=haswell -Rpass="loop|vect" -Rpass-missed="loop|vect" -Rpass-analysis="loop|vect"
# icc on Linux
-Wall -std=c++17 -qopenmp-simd -O3 -ffast-math -march=haswell -qopt-report-file=stdout -qopt-report-format=vs -qopt-report=5 -qopt-report-phase=loop,vec
# msvc
@Trass3r
Trass3r / copyExeAndDependencies.sh
Last active September 21, 2017 11:48
[Linux] create portable app package
# copy $1 to folder $2
ldd $1 | grep -oP '=> \K(/[^(]+)' | xargs cp -vt "$2" "$1"