Skip to content

Instantly share code, notes, and snippets.

;; Set up slime-js
;;
;; To install, see https://github.com/swank-js/swank-js/wiki/Installation
;;
;; This is what I did:
;;
;; npm install swank-js -g
;; M-x package-install slime-js
;;
;; The slime-js version in marmalade requires swank 2010.04.04, or at least
#include <stdlib.h>
#include <stdio.h>
#include <x86intrin.h>
int main(int argc, char** argv) {
__v16si a = {1,2,3,4,5,6,7,8,0,0,0,0,0,0,0,0};
__v16si b = {9,10,11,12,13,14,15,16,1,1,1,1,1,1,1,1};
__v16si c;
c = a+b;
AC_DEFUN_ONCE([_AX_GCC_X86_CPU_INIT],
[AC_LANG_PUSH([C])
AC_CACHE_CHECK([for gcc __builtin_cpu_init function],
[ax_cv_gcc_check_x86_cpu_init],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM([#include <stdlib.h>],
[__builtin_cpu_init ();])
],
[ax_cv_gcc_check_x86_cpu_init=yes],
[ax_cv_gcc_check_x86_cpu_init=no])])
@dryman
dryman / .emacs
Created August 5, 2016 05:26
Minimal org-mode setup
(require 'package)
(setq package-archives
'(("org" . "http://orgmode.org/elpa/")
("gnu" . "http://elpa.gnu.org/packages")
("marmalade"."http://marmalade-repo.org/packages/")
("melpa"."http://melpa.org/packages/")))
(package-initialize)
(defun ensure-package-installed (&rest packages)
"Download the package if it were not installed"
#include <sys/mman.h>
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
int main()
{
ptrdiff_t offset = 1L << 36;
void* addr = NULL + offset;
void* map_addr;
@dryman
dryman / tls_bench.c
Created October 20, 2016 04:35
thread local bench
// gcc -O2 -Wall -pthread tls_bench.c -o tls_bench
// ./tls_bench <num_threads> <loop>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <pthread.h>
#include <assert.h>
#include <stdatomic.h>
__thread int tls = -1;
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <stdatomic.h>
#include <stdbool.h>
static atomic_bool lock = false;
static volatile int counter = 0;
void* thread_start(void *arg)
@dryman
dryman / union.c
Created March 20, 2017 14:37
Polymorphism by GCC transparent union extension (works in clang as well)
typedef enum GenericType GenericType;
typedef struct A A;
typedef struct B B;
enum GenericType
{
TYPE_A = 0,
TYPE_B = 1,
};
heap->occupy_bmap[0] = 0x01;
/* becomes
598 .loc 2 134 3 is_stmt 1 ## lookup_helper_test.c:134:3
599 leaq 72(%r13), %rsi
600 .loc 2 134 24 is_stmt 0 ## lookup_helper_test.c:134:24
601 movq $1, -56(%rbp)
602 leaq -56(%rbp), %rdx
603 movl $8, %edi
604 movl $5, %ecx
# Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install python and nodejs
brew install python3
brew install nodejs
# Install python packages
pip3 install numpy
pip3 install scipy