Skip to content

Instantly share code, notes, and snippets.

View jayeye's full-sized avatar

jayeye

View GitHub Profile
@jayeye
jayeye / kl.json
Created September 12, 2018 20:27
kl
[
{
"name": "Stick",
"author": "JI",
"switchMount": "cherry",
"switchBrand": "cherry",
"switchType": "MX1A-L1Nx",
"pcb": true
},
[
@jayeye
jayeye / README
Created March 11, 2018 23:50
Run chrome in its own memory-limited cgroup
Ugly hack to run chrome in a memory-limited cgroup so it does not kill your workstation
when it tries to consume all available memory.
Put this in /usr/local/bin/cchrome, add that to whatever menu system you are using.
You can verify it worked by running:
grep memory `ps ax | grep chrome | grep -v grep | awk '{printf "/proc/%s/cgroup\n", $1}'`
This has only been tested on kubuntu desktop. Obviously, if you have not enabled
passwordless-sudo for yourself, create and chmod the cgroup directory from some
@jayeye
jayeye / clocks.c
Created February 27, 2018 05:00
demonstrate high-res timers
#include <stdio.h>
#include <time.h>
const int kSamples = 16;
int main(int argc, char* argv[]) {
struct timespec t[kSamples];
for (int i = 0; i < kSamples; ++i) {
clock_gettime(CLOCK_REALTIME, &t[i]);
}
@jayeye
jayeye / vec.cc
Last active January 27, 2018 01:13
Demonstrate how vector<bool> uses much less space than one byte per entry
// * compile without optimization
// * run an inferior shell
// * type limit -d 2048 to restrict the data segment to 2 megs
// * ./a.out
// * profit!
#include <sys/resource.h>
#include <cstdint>
#include <iostream>
@jayeye
jayeye / ubox.el
Created August 5, 2017 23:42
Unicode box drawing characters
; Light and heavy solid lines
;
; 2500 ─ BOX DRAWINGS LIGHT HORIZONTAL
; 2501 ━ BOX DRAWINGS HEAVY HORIZONTAL
; 2502 │ BOX DRAWINGS LIGHT VERTICAL
; 2503 ┃ BOX DRAWINGS HEAVY VERTICAL
;
; Light and heavy dashed lines
;
; 2504 ┄ BOX DRAWINGS LIGHT TRIPLE DASH HORIZONTAL
@jayeye
jayeye / grediting.el
Last active July 19, 2017 23:20
Emacs Lisp definitions for a Greek keyboard
;; DWIM key bindings when I have switched to a greek keyboard mapping
;; By <[email protected]>
;; If you fix something, email me.
(global-set-key (kbd "C-χ") ctl-x-map)
(global-set-key (kbd "M-χ") 'smex)
(global-set-key (kbd "C-α") 'move-beginning-of-line)
(global-set-key (kbd "C-β") 'backward-char)
@jayeye
jayeye / BUILD
Created April 27, 2017 05:00
stamping with build information. Obviously, replace _slash_ in the filenames with an actual slash!
package(default_visibility = ["//visibility:public"])
genrule(
name = "genpybuildinfo",
outs = [
"buildinfo.py",
],
stamp = 1,
cmd = "./$(location tools/mkpybuildinfo.sh) > \"$@\"",
tools = [
@jayeye
jayeye / gist:01eadaa8b679df6e52152ba02760d6cb
Created April 23, 2017 19:09
Hacky way of breaking out of an inner loop. Definitely better than having a flag and testing it.
class _iloop(Exception):
pass
try:
for i in range(2, 10):
for j in range(2, 10):
if i == j * j:
raise _iloop
print(i, j)
except _iloop:
@jayeye
jayeye / sti.c
Created December 8, 2016 03:31
Save buffers of a detached or otherwise inaccessible emacs process.
#include <err.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <termios.h>
const char* const kJesusSaves = "\025\033xsave-buffers-kill-emacs\n";
int main(int argc, char* argv[]) {
int fd = open(argv[1], O_WRONLY);
if (fd < 0) {
@jayeye
jayeye / README.md
Created October 3, 2016 21:45
Setting up ISC dhclient on debian / ubuntu for prefix delegation

My ISP (Time Warner Cable) hands out IPv6 addresses with DHCPv6; it will delegate a /56 if asked. So long as I keep refreshing the lease, it won't renumber me. I have my cable modem set to bridge, and do all the firewalling, NATing, etc., on a Debian box. In what follows, eth0 is the internal interface.

The dhclient that ships with debian/ubuntu does not support asking for a prefix delegation, so I had to build one from sources.