Skip to content

Instantly share code, notes, and snippets.

Gregory Pakosz gpakosz

Block or report user

Report or block gpakosz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
gpakosz / rand.c
Created Nov 8, 2018
PCG32 based floating point random number generation
View rand.c
* Generates a pseudorandom number, in the [0, 1[ interval.
* @param rng Pointer to the pseudorandom number generator.
static inline float rand_f(pcg32_random_t* rng)
const uint32_t max = 1 << 24;
uint32_t r = pcg32_random_r(rng);
r &= max - 1;
return r * 1.0f / max;
gpakosz /
Created Feb 22, 2018
A shell ln() function that defers to mklink on Windows
case $(uname -s) in
ln() {
if ! [ -L "$link" ] && [ -d "$link" ]; then
link="$link/$(basename "$target")"
gpakosz / main.c
Created Oct 27, 2017
memcmp() and sizeof()
View main.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdbool.h>
struct Foo
int i;
gpakosz / main.cpp
Created Mar 7, 2017
uint64_t getChronometerTime() in ms
View main.cpp
#ifdef _WIN32
#include <windows.h>
LARGE_INTEGER frequency; // init with QueryPerformanceFrequency(&frequency) e.g. at beginning of main()
#endif // or go wild and put that in the constructor of a dedicated static object
#ifndef _WIN32
#if defined (CLOCK_MONOTONIC)
#include <time.h>
gpakosz / NVIDIA-GeForce-GT-750M.txt
Created Feb 17, 2017
RealtchVR OpenGL Extension Viewer report for NVIDIA GeForce GT 750M (Late 2013 MacBook Pro)
View NVIDIA-GeForce-GT-750M.txt
Renderer: NVIDIA GeForce GT 750M OpenGL Engine
Vendor: NVIDIA Corporation
Memory: 2048 MB
Version: 4.1 NVIDIA-10.10.14 310.42.25f02
Device: MacBookPro11,3
Shading language version: 4.10
Max texture size: 16384 x 16384
Max vertex texture image units: 16
View array_length.hpp
#include <cstddef>
#define array_length(a) sizeof(impl::array_length_requires_array_argument(a))
namespace impl {
template<typename T, size_t N>
char (&array_length_requires_array_argument(T (&)[N]))[N];
View simplehashing.c
// gcc -O3 -march=native -o simplehashing simplehashing.c
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <string.h>
#include <x86intrin.h>
gpakosz / main.c
Created Nov 11, 2015
printf format string for size_t
View main.c
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1800)
#define SIZET_FMT "%Iu"
#elif defined(__linux__) || (defined(_MSC_VER) && (_MSC_VER >= 1800))
#define SIZET_FMT "%zu"
#elif defined(__APPLE__)
#define SIZET_FMT "%zu"
#define SIZET_FMT "%u"
gpakosz / .gitconfig
Created Oct 8, 2015
My global .gitconfig
View .gitconfig
name = Gregory Pakosz
email = redacted
ui = auto
autocrlf = false
excludesfile = /Users/gregory/.gitignore
editor = vim
whitespace = cr-at-eol
View main.cpp
#include <cstddef>
#include <iostream>
#define array_length(a) sizeof(implementation::array_length_requires_array_argument(a))
namespace implementation {
template<typename T, size_t N>
char (&array_length_requires_array_argument(T (&)[N]))[N];
} // namespace implementation
You can’t perform that action at this time.