Skip to content

Instantly share code, notes, and snippets.

View compor's full-sized avatar

Chris Vasiladiotis compor

  • University of Edinburgh
  • Edinburgh, Scotland, UK
  • 18:31 (UTC +01:00)
View GitHub Profile
@mildsunrise
mildsunrise / dump_vdso_data.c
Last active April 2, 2025 17:35
dumps the data in the vdso_data VVAR (timekeeping info for gettimeofday vDSO)
// WARNING: only for x86
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include <sys/auxv.h>
@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active June 18, 2025 01:58
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@s3rvac
s3rvac / limit-virtual-memory.c
Created December 16, 2017 14:00
Limiting the maximal virtual memory of a process within itself on Linux.
//
// Limits the maximal virtual memory of the process to half of the total
// amount of RAM on the system.
//
// Linux only.
//
// Compilation:
//
// gcc -std=c11 -pedantic limit-virtual-memory.c -o limit-virtual-memory
//
@mbinna
mbinna / effective_modern_cmake.md
Last active June 18, 2025 08:43
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@vext01
vext01 / vimura.md
Last active November 9, 2024 10:33
Vim+Zathura+Synctex

Vim+Zathura+Synctex

  • In a script called 'vimura':
#!/bin/sh
echo $1
zathura -s -x "gvim --servername $1 -c \"let g:syncpdf='$1'\" --remote +%{line} %{input}" $*
@magicznyleszek
magicznyleszek / jekyll-and-liquid.md
Last active January 25, 2025 20:12
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes:

Installing Ruby 2.0.0 on Kindle
===============================
So I've just jailbroken my Kindle, and want to run Ruby on it.
This is what I have right now on my Kindle:
* [KUAL](http://www.mobileread.com/forums/showthread.php?t=203326), the Kindle Unified Applications Launcher
* [KTERM](http://www.fabiszewski.net/kindle-terminal/) with tmux
Make sure you've also enabled `usbnetwork` so that you can SSH to your kindle via USB.
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@gitaarik
gitaarik / git_submodules.md
Last active June 21, 2025 04:43
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
@XVilka
XVilka / TrueColour.md
Last active April 27, 2025 10:17
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!