Skip to content

Instantly share code, notes, and snippets.

View cengiz-io's full-sized avatar

Cengiz Can cengiz-io

View GitHub Profile
@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active April 19, 2025 10:45
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

@cengiz-io
cengiz-io / $HOME|.config|lxc|default.conf
Last active February 16, 2018 08:08
unprivileged lxc setup
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 3e:3f:3a:3b:3c:3d
lxc.idmap = u 0 100000 65536
lxc.idmap = g 0 100000 65536
@qlyoung
qlyoung / linux-clang-format
Created July 17, 2017 18:37
Linux kernel style .clang-format
---
BasedOnStyle: LLVM
Language: Cpp
IndentWidth: 8
UseTab: Always
BreakBeforeBraces: Linux
AlwaysBreakBeforeMultilineStrings: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
;;; ripgrep.el --- from end for ripgrep
;;
;; Copyright (C) 2016 Nicholas Matsakis
;;
;; Adapted from ack-and-a-half.el, which is licensed as follows:
;;
;; Copyright (C) 2011 Jacob Helwig
;;
;; Author: Jacob Helwig <jacob+ack * technosorcery.net>
;; Version: 0.0.1
@ulanda
ulanda / RustJS.md
Last active March 5, 2024 23:31
Rust Compile with asmjs target

You will need nightly Rust

  • Install Rust, se rustup.sh curl -sSf https://static.rust-lang.org/rustup.sh | sh
  • Update installaion with: rustup self update rustup self update-data
  • Install nightly Rust: rustup toolchain install nightly
  • Default to nightly: rustup default nightly

Creating a redis Module in 15 lines of code!

A quick guide to write a very very simple "ECHO" style module to redis and load it. It's not really useful of course, but the idea is to illustrate how little boilerplate it takes.

Step 1: open your favorite editor and write/paste the following code in a file called module.c

#include "redismodule.h"
/* ECHO <string> - Echo back a string sent from the client */
int EchoCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
match cache.entry(sql) {
Occupied(entry) => Ok(entry.get().clone()),
Vacant(entry) => {
let statement = try!(Statement::prepare(&self.raw_connection, entry.key()));
Ok(entry.insert(CachedStatement::new(statement)).clone())
}
}
@vancluever
vancluever / gnome-tracker-disable.md
Last active April 9, 2025 07:13
GNOME Tracker Disable

Disabling GNOME Tracker and Other Info

GNOME's tracker is a CPU and privacy hog. There's a pretty good case as to why it's neither useful nor necessary here: http://lduros.net/posts/tracker-sucks-thanks-tracker/

After discovering it chowing 2 cores, I decided to go about disabling it.

Directories

@coderbyheart
coderbyheart / arch-linux-intel-compute-stick.md
Created January 8, 2016 16:03
Arch Linux on Intel Compute Stick
@butaji
butaji / typeclasses.scala
Created October 20, 2015 19:29
Some playing around Scala's type classes
def foo[A](a: A)(implicit ma: HasSize[A]) = {
ma.size(a)
}
def boo[A : HasSize](a: A) = {
implicitly[HasSize[A]].size(a)
}
trait HasSize[-A] { def size(a: A): Int }