Skip to content

Instantly share code, notes, and snippets.

//
// adder.cpp
//
// CXXFLAGS="-std=c++14 -O3 -ggdb -ggdb3" make adder
//
#include <iostream>
#include <cstdint>
#include <sys/mman.h>
git init .
echo Documentation/ > ./.git/info/sparse-checkout
git config core.sparsecheckout true
git remote add origin https://github.com/git/git.git
git pull origin master
@kaushiks
kaushiks / gist:751b6fd9ab63b98f5fc72982bab18ddc
Last active November 12, 2016 16:09
Installing Debian on a 2016 X1 Carbon
# /etc/X11/xorg.conf.d/20-intel.conf
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "TripleBuffer" "on"
Option "SwapbufferWait" "on"
Option "TearFree" "true"
EndSection
# From http://www.thinkwiki.org/wiki/How_to_configure_the_TrackPoint
@kaushiks
kaushiks / compiler.cc
Last active February 19, 2018 06:23
A simple LLVM based backend compiler: Emitting a module
#include "llvm/IR/Module.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/Support/raw_ostream.h"
static llvm::LLVMContext g_context;
#define getGlobalContext() (g_context)
@kaushiks
kaushiks / Makefile
Last active December 23, 2022 17:06
A reentrant C++ flex scanner.
all:
flex flex-scanner.l
g++ -o d flex-scanner.c scanner.cc main.cc
test: all
./d
clean:
rm ./d
rm ./flex-scanner.c
author Kaushik Srenevasan <ksrenevasan@gmail.com> 2012-03-13 07:07:10 (GMT)
committer Glenn Morris <rgm@gnu.org> 2012-03-13 07:07:10 (GMT)
commit 4a07df36a52547d272107151e9251ba96cb37224 (patch) (side-by-side diff)
tree 0a8e4a84a982a8a3e303aa7cdc97723d3a360647
parent 4aaa93566b7bbc3cb57e6c15b4c5bc5a140b3355 (diff)
download emacs-4a07df36a52547d272107151e9251ba96cb37224.tar.gz
GDB change for dynamically generated code (tiny change)
Ref: http://lists.gnu.org/archive/html/emacs-devel/2012-01/msg00753.html
* lisp/progmodes/gdb-mi.el (gdb-invalidate-disassembly):
@kaushiks
kaushiks / FieldLayoutPrinter.java
Last active December 21, 2015 11:29
Java (Hotspot) class layout printer.
import sun.misc.Unsafe;
import java.lang.reflect.*;
import java.util.*;
class FieldLayoutPrinter {
private static Unsafe _unsafe = null;
static {
try {
Field field = Unsafe.class.getDeclaredField("theUnsafe");
field.setAccessible(true);
@kaushiks
kaushiks / curry.cc
Created May 15, 2013 02:46
Currying in C++
#include <stdio.h>
class Adder {
public:
Adder(int n): n(n) {}
int operator()(int other) { return other + n; }
private:
int n;
};