Skip to content

Instantly share code, notes, and snippets.

View pendingchaos's full-sized avatar

PendingChaos pendingchaos

  • Earth
View GitHub Profile
@e7d
e7d / remove-obsolete-gpg-key-from-dnf.md
Last active July 19, 2024 15:51
Remove obsolete GPG key from DNF (Fedora)
@pendingchaos
pendingchaos / path.c
Created March 29, 2016 09:34
An extremely compact PATH implementation
#include<stdio.h>
#define A while((z=getc(f))^EOF)if(z=='\n')++Y,X=0;else{if
#define Z x+=(K&3)-1,y+=(K>>3)-1
#define J :z==
#define v m[C]
int m[30000];size_t s,C,r=1,K=10,x,y,X,Y=1;int main(int l,char**u){FILE*f=fopen(u[1],"r");char z;A(z=='$')break;++X;}x=X;y=Y;while(r){rewind(f);X=0,Y=1;A(X==x&Y==y)break;++X;}z=='#'?r=0 J'+'?v++J'-'?v--J'}'?C++J'{'?C--J','?v=getchar()J'.'?putchar(v)J'/'?K=K==10?1:K==17?8:K==8?17:10 J'\\'?K=K==10?17:K==17?10:K==8?1:8 J'^'?K=v?1:K J'<'?K=v?8:K J'>'?K=v?10:K J'v'?K=v?17:K J'!'?Z:0;Z;}return fclose(f);}
@pendingchaos
pendingchaos / Makefile
Last active April 23, 2016 12:35
A Makefile
CFLAGS = -pedantic -Wall -std=c11 -g
LDFLAGS =
OUTPUT =
RUN_OPT =
PREFIX ?= /usr/local
TARGET = $@
PREREQ1 = $<
src = $(wildcard src/*.c)
@pendingchaos
pendingchaos / README.md
Last active September 6, 2018 11:11
Base XScreensaver hack or screensaver

Installation

  • Copy base.xml to /usr/share/xscreensaver/config
  • Copy the compiled base.c (named "base") to /usr/libexec/xscreensaver
  • Add "GL: base -root\n" to programs in .xscreensaver in your home directory.
@pendingchaos
pendingchaos / aabb_tranform.c
Last active January 29, 2016 15:19
AABB transformation
//-O0: SSE is ~6.3x faster
//-O1: SSE is ~4.6x faster
//-O2: SSE is ~2.5x faster
//-O3: SSE is ~2.2x faster
//-Og: SSE is ~5.5x faster
//-Ofast: SSE is ~1.7x faster
//-Os: SSE is ~2.3x faster
//You probably should not trust these timings.
//Compiled with GCC 5.3.1
//Ran on a Intel(R) Core(TM) i7-3770K CPU
@pendingchaos
pendingchaos / style.css
Last active November 14, 2017 17:35
Opinionated Stylish Style for Twitter.
@-moz-document url("https://twitter.com/") {
body {
background-color: #131515;
background: #131515;
}
body:not(.edge-design) {
background-color: #131515 !important;
background: #131515 !important;
}
}
@pendingchaos
pendingchaos / gtk3.supp
Last active January 29, 2016 15:19
A Valgrind suppression file for GTK+ applications. Just add --suppressions=/path/to/gtk3.supp.
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: possible
fun:calloc
fun:g_malloc0
obj:/usr/lib64/libgobject-2.0.so.0.4200.2
fun:g_type_register_fundamental
obj:/usr/lib64/libgobject-2.0.so.0.4200.2
obj:/usr/lib64/libgobject-2.0.so.0.4200.2
@pendingchaos
pendingchaos / matrix_mul.cpp
Last active October 23, 2019 21:10
SSE 4x4 matrix multiplication
#include <xmmintrin.h>
//~2.4x faster than non-SSE unrolled version.
//Uses row-major order (D3D or non-OpenGL layout).
void mul(float result[4][4], float a[4][4], float b[4][4])
{
__m128 otherRow0 = _mm_loadu_ps(b[0]);
__m128 otherRow1 = _mm_loadu_ps(b[1]);
__m128 otherRow2 = _mm_loadu_ps(b[2]);
__m128 otherRow3 = _mm_loadu_ps(b[3]);
@pendingchaos
pendingchaos / README.md
Last active October 7, 2015 14:01
Translates a text a gazillion times then into English to produce awesomeness.

Example usage

cat <input file> | python2 gobbledygook.py > <output file>

Sample output

Rudolph, the Red-Nosed Reindeer
The nose is very strong.
If you do not see,
It should be great.

@pendingchaos
pendingchaos / partialpartial.cpp
Created July 25, 2015 20:36
Partial partial function application.
#include <cstdio>
template <typename R, typename A1, typename... Args>
class _partialpartial
{
public:
typedef R R_type;
_partialpartial(R (*func_)(A1, Args...),
A1 arg1_) : func(func_), arg1(arg1_) {}