Skip to content

Instantly share code, notes, and snippets.

View Trass3r's full-sized avatar

Trass3r Trass3r

View GitHub Profile
// https://godbolt.org/g/tg84qZ
#include <cstdint>
#include <cstdlib>
//! return the length in code points
size_t utf8strlen(const char* ptr)
{
size_t i = 0, l = 0;
while (ptr[i])
#pragma once
#include <cstdint>
#include <cstddef>
#include <cstdlib>
#include <type_traits>
#define IS_64BIT (__x86_64__ || _M_X64 || __aarch64__)
#define IS_THUMB (__thumb__ || _M_ARMT)
#define IS_ARM (__arm__ || _M_ARM || __aarch64__)
@Trass3r
Trass3r / GLFWexample.cpp
Created December 8, 2017 09:28
OpenGL with GLFW and GLEW
#define GLEW_STATIC
#include <GL/glew.h> // include GLEW and new version of GL on Windows
#include <GL/glfw.h> // GLFW helper library
#include <stdio.h>
#include <string>
static void listVideoModes()
{
int count = 0;
GLFWvidmode list[32];
struct MeasureAndPrintTime
{
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
~MeasureAndPrintTime()
{
auto diff = std::chrono::steady_clock::now() - start;
auto usecs = std::chrono::duration_cast<std::chrono::microseconds>(diff).count();
printf("took %lldus\n", (long long)usecs);
}
// An implementation of the Aho-Corasick algorithm for string matching
// using static arrays for the functions
// http://en.wikipedia.org/wiki/Aho-Corasick_algorithm
module automaton;
import queue;
public import keyword;
public import list;
@Trass3r
Trass3r / Win10PhotoViewer.reg
Created January 29, 2018 14:22
bring back Win7 photo viewer
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll]
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell]
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open]
"MuiVerb"="@photoviewer.dll,-3043"
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\command]
@Trass3r
Trass3r / simpletiff.h
Last active June 8, 2022 14:07
simple TIFF writer
#pragma once
#include <cstdint>
#include <memory>
enum class TYPE : uint16_t
{
None = 0,
BYTE, ASCII, SHORT, LONG, RATIONAL,
SBYTE, UNDEF, SSHORT, SLONG, SRATIONAL,
@Trass3r
Trass3r / scopedenumutils.h
Last active April 8, 2019 14:22
esp. for flags enums
#pragma once
#include <type_traits>
template <typename T>
using is_scoped_enum = std::integral_constant<bool, std::is_enum<T>::value && !std::is_convertible<T, int>::value>;
template <typename T>
constexpr bool is_scoped_enum_v = is_scoped_enum<T>::value;
@Trass3r
Trass3r / changes.diff
Last active December 12, 2019 11:24
LLVM setup
diff --git a/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp b/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
index fa7c352a1b6..e83c14d47e6 100644
--- a/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
+++ b/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
@@ -25,7 +25,7 @@ enum AsmWriterFlavorTy {
};
static cl::opt<AsmWriterFlavorTy> AsmWriterFlavor(
- "x86-asm-syntax", cl::init(ATT), cl::Hidden,
+ "x86-asm-syntax", cl::init(Intel), cl::Hidden,
/*!
* Copyright (C) 2017-2018 Andreas Hollandt
*
* Distributed under the Boost Software License, Version 1.0.
* See copy at http://boost.org/LICENSE_1_0.txt.
*/
#pragma once
#include <exception>