Skip to content

Instantly share code, notes, and snippets.

View electromatter's full-sized avatar

Eric Chai electromatter

  • Washington, D.C.
  • 18:39 (UTC -04:00)
View GitHub Profile
!xterm*reverseVideo: off
xterm*locale: true
xterm*faceName: DeJaVu Sans Mono:size=9
xterm*vt100*translations: #override \n\
Shift <Key> Delete: insert-selection(SELECT) \n\
Shift Ctrl <Key> C: select-end(CLIPBOARD) \n\
Shift Ctrl <Key> V: insert-selection(CLIPBOARD) \n\
Shift Ctrl <Key> N: spawn-new-terminal() \n
xterm*selectToClipboard: true
xterm*metaSendsEscape: true
@electromatter
electromatter / colors.reg
Last active March 13, 2019 19:00
My putty colors
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Default%20Settings]
; Default foreground color normal/bold
"Colour0"="53,53,53"
"Colour1"="102,102,102"
; Default background normal/bold
"Colour2"="255,255,240"
@electromatter
electromatter / curse.py
Last active February 21, 2019 17:08
Curse forge MultiMC downloader
#!/usr/bin/env python3
# Copyright (c) 2019, Eric Chai <electromatter@gmail.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@electromatter
electromatter / .gvimrc
Last active August 19, 2018 00:45
gvim config in addition to my vimrc
colors electromatter
set guifont=DejaVu\ Sans\ Mono:h9
set noeb vt t_vb=
set guioptions=
set guicursor=a:blinkon0,a:block
set belloff=all
function triangle_hmac_sha256(rounds, key /* ... */) {
var hmac = new Hmac_ctx(Sha256_ctx, key),
digests = new Array(rounds);
for (var i = 2; i < arguments.length; i++)
hmac.update(arguments[i]);
digests[0] = hmac.finalize();
for (var i = 1; i < rounds; i++) {
/* rb.c - Red Black trees
*
* Copyright (c) 2016, Eric Chai <electromatter@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@electromatter
electromatter / dwptr.h
Last active May 14, 2016 05:11
ghostptr.c
/* dwptr.h - Double pointer compare and swap
*
* Copyright (c) 2016, Eric Chai <electromatter@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@electromatter
electromatter / ghostptr.txt
Last active May 9, 2016 02:19
ghost pointers
(* ghost_mask must be one less than a power of two and must be greater or equal
* to the number of threads concurrently calling grab or swap a pointer_t
*
* The type holding thease values must be large enough to hold a mutation count
* that is large enough to have an extremely low change of overflowing. Overflow
* of the mutation counter is expected to be ignored and wrap around without
* changing the ghost counter.
*
* Care should be excercised when selecting ghost_mask, the value:
* ghost_mask * <max number of pointer_t to object_t> + <max number of other references to object_t>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <limits.h>
#include <errno.h>
#include <unistd.h>
#include <pthread.h>
#include <time.h>
#define atomic_add(ptr, value) __sync_add_and_fetch(ptr, value)
/* base64.c
*
* Copyright (c) 2016, Eric Chai <electromatter@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF