THIS GIST WAS MOVED TO TERMSTANDARD/COLORS
REPOSITORY.
PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!
THIS GIST WAS MOVED TO TERMSTANDARD/COLORS
REPOSITORY.
PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!
This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.
The script is here:
#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"
// ---- Straightforward: | |
__m128i lo_int = _mm_and_si128(_mm_set1_epi32(0xffff), in); // low 16 bits of all vals | |
__m128i hi_int = _mm_srli_epi32(in, 16); // high 16 bits of all vals | |
__m128 lo_flt = _mm_cvtepi32_ps(lo_int); // exact (all 16 bit ints = machine numbers) | |
__m128 hi_flt = _mm_cvtepi32_ps(hi_int); // exact | |
__m128 hi_scl = _mm_mul_ps(hi_flt, _mm_set1_ps(65536.0f)); // exact (just exponent change) | |
__m128 result = _mm_add_ps(hi_scl, lo_flt); // this is the only step that rounds. | |
// same approach also works with FMA where available. |
max(-x,-y) = -min(x,y) | |
min(-x,-y) = -max(x,y) | |
abs(x) = abs(-x) | |
abs(x) = max(x,-x) = -min(x,-x) | |
abs(x*a) = if (a >= 0) abs(x)*a | |
(a < 0) -abs(x)*a | |
// basically any commutative operation | |
min(x,y) + max(x,y) = x + y |
// Mini memory editor for Dear ImGui (to embed in your game/tools) | |
// Animated GIF: https://twitter.com/ocornut/status/894242704317530112 | |
// THE MEMORY EDITOR CODE HAS MOVED TO GIT: | |
// https://github.com/ocornut/imgui_club/tree/master/imgui_memory_editor | |
// Click "Revisions" on the Gist to see old version. |
Memory Optimization (Christer Ericson, GDC 2003)
http://realtimecollisiondetection.net/pubs/GDC03_Ericson_Memory_Optimization.ppt
Cache coherency primer (Fabian Giesen)
https://fgiesen.wordpress.com/2014/07/07/cache-coherency/
Code Clinic 2015: How to Write Code the Compiler Can Actually Optimize (Mike Acton)
http://gdcvault.com/play/1021866/Code-Clinic-2015-How-to
# Download latest archlinux bootstrap package, see https://www.archlinux.org/download/ | |
wget 'ftp://ftp.nluug.nl/pub/os/Linux/distr/archlinux/iso/latest/archlinux-bootstrap-*-x86_64.tar.gz' | |
# Make sure you'll have enough entropy for pacman-key later. | |
apt-get install haveged | |
# Install the arch bootstrap image in a tmpfs. | |
mount -t tmpfs none /mnt | |
cd /mnt | |
tar xvf ~/archlinux-bootstrap-*-x86_64.tar.gz --strip-components=1 |
/// zzz - very sleepy replacement, based on etw | |
#define INITGUID | |
#include <windows.h> | |
#include <psapi.h> | |
#include <tdh.h> | |
#include <evntrace.h> | |
#include <guiddef.h> | |
#pragma warning(disable: 4091) | |
#include <dbghelp.h> |
Why do compilers even bother with exploiting undefinedness signed overflow? And what are those | |
mysterious cases where it helps? | |
A lot of people (myself included) are against transforms that aggressively exploit undefined behavior, but | |
I think it's useful to know what compiler writers are accomplishing by this. | |
TL;DR: C doesn't work very well if int!=register width, but (for backwards compat) int is 32-bit on all | |
major 64-bit targets, and this causes quite hairy problems for code generation and optimization in some | |
fairly common cases. The signed overflow UB exploitation is an attempt to work around this. |