Skip to content

Instantly share code, notes, and snippets.

@tckmn
tckmn / 08.rb
Created December 8, 2020 05:28
aoc 2020 day 8
def f idx
code = read.lines.map{|x|
a,b = x.split
[a,b.to_i]
}
return if code[idx][0] == 'acc'
code[idx][0] = code[idx][0] == 'jmp' ? 'nop' : 'jmp'
executed = code.map{false}
@tckmn
tckmn / script.sh
Last active March 31, 2020 19:35
stack exchange dark theme
#!/usr/bin/env bash
go() {
curl $1$2 | sed 's!url(\(.\)\.\.!url(\1'$1'..!g'
}
{
go https://cdn.sstatic.net/Shared/ stacks.css
go https://cdn.sstatic.net/Sites/stackoverflow/ primary.css
} | sed '
s/theme-dark/unified-theme/g;
s/prefers-color-scheme:dark/min-width:1px/g;
1-INDEXED, TOP TO BOTTOM, 2D
[[8, 10, 3, 11], [2, 11, 8, 12], [1, 7, 4, 9], [8, 7, 11, 13], [1, 12, 6, 13], [2, 7, 11, 1], [7, 12, 8, 3], [9, 5, 6, 10], [13, 13, 4, 5], [2, 6, 12, 4], [3, 5, 9, 10], [5, 4, 9, 10], [6, 1, 3, 2]]
[[8, 5, 4, 13], [11, 3, 7, 9], [11, 6, 12, 12], [4, 2, 6, 9], [10, 1, 3, 1], [6, 10, 9, 11], [6, 4, 7, 2], [8, 5, 13, 7], [5, 10, 3, 13], [2, 7, 1, 3], [1, 13, 8, 10], [12, 9, 8, 5], [12, 4, 2, 11]]
[[11, 6, 13, 12], [9, 1, 9, 5], [11, 12, 13, 8], [3, 8, 13, 5], [3, 7, 3, 7], [1, 8, 6, 13], [8, 12, 9, 6], [11, 4, 5, 2], [10, 2, 1, 7], [1, 6, 9, 3], [2, 11, 10, 4], [5, 2, 7, 4], [10, 4, 10, 12]]
[[7, 12, 1, 5], [5, 6, 11, 11], [5, 11, 3, 4], [7, 12, 9, 13], [12, 1, 4, 8], [4, 9, 3, 13], [7, 10, 10, 6], [1, 3, 13, 10], [1, 8, 6, 4], [6, 5, 12, 13], [10, 2, 2, 3], [9, 9, 8, 2], [2, 7, 8, 11]]
[[11, 10, 12, 9], [9, 8, 8, 4], [10, 13, 5, 13], [5, 13, 5, 6], [2, 6, 9, 2], [11, 4, 3, 8], [3, 10, 12, 11], [1, 7, 5, 9], [7, 6, 4, 3], [12, 7, 2, 7], [11, 4, 10, 3], [1, 12, 13, 6], [1, 2, 8, 1]]
@tckmn
tckmn / input.txt
Created December 19, 2018 19:29
Bookworm Deluxe dictionary
aa
2h
3ed
ing
s
2l
3iis
s
2rdvark
8s
@tckmn
tckmn / setlocale.cpp
Last active December 3, 2017 16:21
setlocale for Haiku
/*
* Copyright 2017 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Andrew Tockman, andy@keyboardfire.com
*/
#include <stdio.h>
#include <stdlib.h>
@tckmn
tckmn / test.cpp
Created December 3, 2017 00:05
broken GetHasGlyphs call
#include <Font.h>
#include <String.h>
int main()
{
BString str("test");
int len = str.CountChars();
bool has[len];
be_fixed_font->GetHasGlyphs(str.String(), len, has);
}
@tckmn
tckmn / keymap.c
Created November 19, 2017 17:15
my qmk config
#include "planck.h"
#include "action_layer.h"
#include "virtser.h"
#include "keymap_steno.h"
extern keymap_config_t keymap_config;
#define QWERTY 0
#define PLOVER 1
#define RAISE 2
@tckmn
tckmn / pacman.r
Created January 16, 2017 02:24
density plot of pacman / alpm transactions by time of day
# license: unlicense <http://unlicense.org/>
times <- system2('bash', args=c('-c', shQuote('grep "\\[ALPM\\] transaction started" /var/log/pacman.log | cut -c 13-17')), stdout=TRUE)
times <- strtoi(substr(times, 1, 2), 10) + strtoi(substr(times, 4, 5), 10) / 60
plot(density(c(times-24, times, times+24), bw=0.3), xlim=range(0:24), xaxs="i", axes=FALSE)
axis(side=1, at=c(0:24), las=2)
box()
@tckmn
tckmn / keymap.c
Created November 19, 2016 02:21
Planck keymap (qmk)
#include "planck.h"
#include "action_layer.h"
extern keymap_config_t keymap_config;
#define QWERTY 0
#define PLOVER 1
#define RAISE 2
#define DEAD 3
#define RAISE_DEAD 4
#![feature(try_from)]
use std::{ops,convert,clone,fmt};
fn generic_odds<T>(v: &Vec<T>) -> Vec<T>
where T: ops::Rem<T> + convert::TryFrom<u8> + clone::Clone,
<T as ops::Rem<T>>::Output: PartialEq<T>,
<T as convert::TryFrom<u8>>::Err: fmt::Debug {
v.iter().cloned().filter(|elt| {
elt.clone() % T::try_from(2u8).unwrap() == T::try_from(1u8).unwrap()