Skip to content

Instantly share code, notes, and snippets.

@xvrdm
xvrdm / config
Created February 28, 2024 13:15 — forked from zerosign/config
i3 config file
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
@xvrdm
xvrdm / AdventOfCode2021_d04_main.R
Last active December 4, 2021 16:28
Advent of Code 2021 in R - Day 4
library(tidyverse)
raw_data <- readr::read_lines("days/d04/data.txt") %>%
stringr::str_trim()
BOARD_SIZE <- 5
draws <- raw_data[1] %>%
stringr::str_split(",") %>%
.[[1]] %>%
@xvrdm
xvrdm / AdventOfCode2021_d03_main.R
Last active December 3, 2021 13:19
Advent of Code 2021 in R - Day 3
library(tidyverse)
binary_flip <- function(x) ifelse(x=="1","0","1")
bits_seq_to_decimal <- function(x) strtoi(paste0(x, collapse = ""), base=2)
# Challenge 1
bits <- readr::read_lines("days/d03/data.txt") %>%
stringr::str_split("")
@xvrdm
xvrdm / AdventOfCode2021_d02_main.R
Last active December 4, 2021 20:55
Advent of Code 2021 in R - Day 2
library(tidyverse)
input <- readr::read_lines("days/d02/data.txt") %>%
stringr::str_split(" ")
# Challenge 1
hor <- input %>%
purrr::keep(~ .[1] == "forward") %>%
purrr::map_dbl(~as.numeric(.[2])) %>%
sum
@xvrdm
xvrdm / AdventOfCode2021_d01_main.R
Last active December 2, 2021 13:58
Advent of Code 2021 in R - Day 1
# ------------------------------------------------------------------------------------------
# Solution with Reduce
# Challenge 1
find_increase <- function(accumulated, next_val) {
is_increase = !is.na(accumulated$previous) && accumulated$previous < next_val
list(
previous = next_val,
count = accumulated$count + ifelse(is_increase, 1, 0)
)
}
@xvrdm
xvrdm / SuperWinKey.ahk
Created May 20, 2021 20:13
SuperWinKey
GroupAdd, NoMod , ahk_exe VirtualBoxVM.exe ;Desktop
#IfWinNotActive, ahk_group NoMod
#Persistent
SetCapsLockState, AlwaysOff
; Capslock alone should send Esc
; Capslock::Send {esc}
Capslock::SendInput {Blind}{Esc}
@xvrdm
xvrdm / machine.js
Created December 15, 2020 13:57
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@xvrdm
xvrdm / between_caveat
Created December 2, 2020 09:52
{dplyr}'s between cannot take multiple values vectors for left/right boundaries
> between(c(5,6), left = c(1,4), right = c(2,10))
[1] FALSE FALSE
> tibble(val = c(5,6), min_threshold = c(1,4), max_threshold = c(2,10)) %>%
mutate(is_in_range = between(val, min_threshold, max_threshold))
# A tibble: 2 x 4
val min_threshold max_threshold is_in_range
<dbl> <dbl> <dbl> <lgl>
1 5 1 2 FALSE
tribble(
~Shoe, ~Max_Size, ~Min_Size,
"sneakers", 34, 28,
"leather", 39, 30)
@xvrdm
xvrdm / gist:72e7eb17fa0f351a1d7550663f8bf713
Created February 7, 2019 13:51
Gruvbox Colorscheme for Kitty Terminal
#: Color scheme {{{
foreground #ebdbb2
background #282828
#: black
color0 #282828
color8 #928374
#: red