Skip to content

Instantly share code, notes, and snippets.

@Porges
Porges / evil.cs
Last active October 2, 2017 21:56
unsafe void Main()
{
var s = "hello world";
Console.WriteLine($"String hash code: {s.GetHashCode()}");
var hashCode = RuntimeHelpers.GetHashCode(s);
Console.WriteLine($"Object hash code: {hashCode}");
Console.WriteLine("Poking string...");
fixed (char* cs = s)
@nkurz
nkurz / l1d.c
Created December 26, 2015 23:32
Are sustained loads of 64B per cycle possible on Haswell and Skylake?
// gcc -fno-inline -std=gnu99 -Wall -O3 -g -march=native l1d.c -o l1d
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <x86intrin.h>
#include <math.h>
@gtallen1187
gtallen1187 / scar_tissue.md
Created November 1, 2015 23:53
talk given by John Ousterhout about sustaining relationships

"Scar Tissues Make Relationships Wear Out"

04/26/2103. From a lecture by Professor John Ousterhout at Stanford, class CS142.

This is my most touchy-feely thought for the weekend. Here’s the basic idea: It’s really hard to build relationships that last for a long time. If you haven’t discovered this, you will discover this sooner or later. And it's hard both for personal relationships and for business relationships. And to me, it's pretty amazing that two people can stay married for 25 years without killing each other.

[Laughter]

> But honestly, most professional relationships don't last anywhere near that long. The best bands always seem to break up after 2 or 3 years. And business partnerships fall apart, and there's all these problems in these relationships that just don't last. So, why is that? Well, in my view, it’s relationships don't fail because there some single catastrophic event to destroy them, although often there is a single catastrophic event around the the end of the relation

@mattwarren
mattwarren / ClrToStringOverrides.cs
Created May 13, 2015 11:25
Using Cecil to find all the types in "System." assemblies that DON'T override ToString()
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Mono.Cecil;
namespace ClrToStringOverrides
{
internal class Program
{
@hraban
hraban / pre-commit.md
Last active April 18, 2024 06:46
Prevent accidentally committing debug code in Git
@tobiasviehweger
tobiasviehweger / OutlookPSTStoreTodos.cs
Created May 5, 2015 10:11
Enable "Display reminders and tasks from this folder in the To-Do bar" for PST Store programatically
private void EnableStoreTodosAndReminders(RDOStore store)
{
//Enable store for reminders
var reminders = store.Reminders;
reminders.EnableStoreReminders();
//Collection some folders we need
var rootFolder = store.RootFolder;
var taskFolder = store.GetDefaultFolder(rdoDefaultFolders.olFolderTasks);
var inbox = store.GetDefaultFolder(rdoDefaultFolders.olFolderInbox);
@noelwelsh
noelwelsh / Nullable.scala
Created April 17, 2015 10:38
Nullable types in Scala
object Nullable {
sealed trait NullableTag
type Nullable[A] = A with NullableTag
def nullAs[B]: Nullable[B] =
null.asInstanceOf[Nullable[B]]
implicit class ToNullable[A](val a: A) extends AnyVal {
def `?`: Nullable[A] = a.asInstanceOf[Nullable[A]]
}
@XVilka
XVilka / BiDiSupport.md
Last active October 15, 2025 12:43
BiDirectional Text

This gist will show the support of BiDirectional text in the terminal emulators and console programs. You can read more about the standardization efforts at the dedicated page of FreeDesktop Terminal BiDi working group.

How to test

Logical Order ◀ ◀ ◀ RTL LTR ▶ ▶ ▶
WHAT IS UNICODE؟ in arabic in arabic ؟EDOCINU SI TAHW ؟EDOCINU SI TAHW in arabic
ما هو الترميز الموحد يونيكود؟ in Arabic ما هو الترميز الموحد يونيكود؟ in Arabic
@orlp
orlp / chacha.h
Last active August 18, 2025 14:08
C++11 ChaCha implementation.
/*
Copyright (c) 2024 Orson Peters <orsonpeters@gmail.com>
This software is provided 'as-is', without any express or implied warranty. In no event will the
authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the
@lavalamp
lavalamp / The Three Go Landmines.markdown
Last active February 28, 2025 12:54
Golang landmines

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }