Skip to content

Instantly share code, notes, and snippets.

View Airtnp's full-sized avatar
💭
Studying for ever

LR.X Airtnp

💭
Studying for ever
View GitHub Profile
@Badel2
Badel2 / spectre.c
Last active March 12, 2023 00:18
Spectre attack example implementation
/* https://spectreattack.com/spectre.pdf */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@LYP951018
LYP951018 / Future.cpp
Last active May 30, 2017 12:49
NaiveFuture
#include <variant>
#include <functional>
#include <memory>
#include <iostream>
#include <thread>
#include <chrono>
#include <stdexcept>
#include <Windows.h>
using Win32Handle = std::unique_ptr<void, void (*)(void *) noexcept>;
@CMCDragonkai
CMCDragonkai / existential_types_haskell.md
Last active June 10, 2020 06:48
Existential Types in Haskell

Existential Types in Haskell

I had always been confused by Haskell's implementation of existential types. Until now!

Existential types is the algebraic data type (ADT) equivalent to OOP's data encapsulation. It's a way of hiding a type within a type. Hiding it in such a way that any consumer of the data type won't have any knowledge on the internal property

@rangercyh
rangercyh / print_lua_table.lua
Last active November 5, 2021 07:39
按照lua的table格式进行缩进打印lua的table,目前还不支持key为table,因为是自己还没想好,如果key是table的时候怎么打印出来比较优美
function print_lua_table (lua_table, indent)
indent = indent or 0
for k, v in pairs(lua_table) do
if type(k) == "string" then
k = string.format("%q", k)
end
local szSuffix = ""
if type(v) == "table" then
szSuffix = "{"
end