Skip to content

Instantly share code, notes, and snippets.

View willowiscool's full-sized avatar

Willow Veytsman willowiscool

View GitHub Profile
@willowiscool
willowiscool / aoc2023.js
Created December 23, 2023 08:52
advent of code 2023 in javascript one-liners
// day 1 part 1
document.body.innerText.trim().split("\n").map(e=>Number(/^\D*(\d)/.exec(e)[1]+/(\d)\D*$/.exec(e)[1])).reduce((a,b)=>a+b)
// day 1 part 2
document.body.innerText.trim().split("\n").map(e=>e.replace(/one|two|three|four|five|six|seven|eight|nine/g,d=>[0,"one","two","three","four","five","six","seven","eight","nine"].indexOf(d))).map(e=>Number(/^\D*(\d)/.exec(e)[1]+/(\d)\D*$/.exec(e)[1])).reduce((a,b)=>a+b)
// you could golf this more --- something like ...replace(new RegExp((a=[...]).join`|`,"g"),d=>a.indexOf(d))...
// day 2 part 1
document.body.innerText.trim().split("\n").filter(g=>g.split(";").map(d=>(Number((/(\d+) b/.exec(d)||[0,0])[1])<=14)&&(Number((/(\d+) g/.exec(d)||[0,0])[1])<=13)&&(Number((/(\d+) r/.exec(d)||[0,0])[1])<=12)).reduce((a,b)=>a&&b)).map(g=>Number(g.match(/\d+/)[0])).reduce((a,b)=>a+b)
// day 2 part 2
document.body.innerText.trim().split("\n").map(g=>g.split(";").map(d=>[Number((/(\d+) r/.exec(d)||[0,0])[1]),Number((/(\d+) g/.exec(d)||[0,0])[1]),Number((/(\d+) b/.exec(d)|
@willowiscool
willowiscool / .Minecraft Gradient Skin Maker.md
Last active February 25, 2021 16:54
Minecraft gradient skin creator. Change COLORONE and COLORTWO

Change the variables COLORONE and COLORTWO and run to get your skin in output.png

@willowiscool
willowiscool / uploadToS3.sh
Created March 22, 2020 00:06
Upload what's in the clipboard to S3 (interactive file name input)
#!/usr/bin/env bash
BUCKET="vityavv-imagebin"
target=$(xclip -sel clip -o -t TARGETS | tail -1)
mime="$target"
[[ "$mime" == *"/"* ]] || mime="text/plain"
filename=$(yad --entry --title "S3 Uploader" --center --text "S3 Uploader\nClipboard type is $target" --text-align=center --entry-label="Filename:" 2>/dev/null || echo "STOP THIS")
[ "$filename" == "STOP THIS" ] && exit 1
@willowiscool
willowiscool / decksToQuizlet.js
Last active January 13, 2020 04:02
This script translates a decks.memrise list to a format you can import into quizlet. To use it, paste it into the browser console of a decks list page, and copy the result into quizlet's import!
Array.from(document.querySelectorAll("div.things.clearfix .text-text .text .text")).map(e=>e.textContent).reduce((a,b)=>(a[a.length-1].length<2?a[a.length-1].push(b):a.push([b]),a),[[]]).map(e=>e.join(" ")).join("\n")
@willowiscool
willowiscool / copypasta.sh
Created January 5, 2020 18:21
A program that'll help you with copypastas using rofi
# Made by Victor Veytsman
# Usage: have a copypastas.txt file with your copypastas.
# Separate your copypastas with three equal signs
# Separate the name of the copypasta and the text with three semicolons
# Make this file executable and bind it to some keybinding
getList() {
grep -o '^.*;;;' copypastas.txt | sed 's/...$//g'
}
@willowiscool
willowiscool / _about.md
Last active December 18, 2021 06:18
An Advent of Code light theme

AOC light theme

This is a light theme for advent of code. style.css contains the style. bookmarklet.html can be visited with rawgit (that's the direct link to bookmarklet.html) to find a bookmarklet that can be dragged to your bookmarks bar and then pressed to make the AOC webpage light.

@willowiscool
willowiscool / imagerandvoronoi.go
Last active March 16, 2019 02:55
Program creates a voronoi diagram using random sites, then colors in each site with the average color of all of the pixels contained in the site. https://blog.victor.computer/article/3
package main
import (
"math/rand"
"image/draw"
"image/png"
"image/color"
"strconv"
"os"
"time"
@willowiscool
willowiscool / .vimrc
Created December 8, 2018 18:45
My current vimrc
" Get the defaults that most users want.
source $VIMRUNTIME/defaults.vim
" Set colors be good
set termguicolors
colorscheme gruvbox
set background=dark
set cursorline
" Set search to highdark incomplete, case insensitive, highlight
set hls is ic
set number relativenumber
@willowiscool
willowiscool / aoc.js
Created December 2, 2018 22:06
Advent of Code 2018... GOLFED!
// This is my list of solutions to the Advent of Code challanges
// They are written in JavaScript, with the goal of getting the
// size of them to be as small as possible.
// Each one assumes that the variable y is an array of the body's
// contents. You can get that by doing the following in the
// browser console of the input:
y=document.body.innerText.split("\n")
// The documents may have a trailing newline, but you can do this
// to solve that
y=y.slice(0,y.length-1)
@willowiscool
willowiscool / info.md
Created May 11, 2018 14:42
A chat server with node's net module.

How to use

Run the file. The port is on the last line (no. 13) so you can change that.

In another terminal, on the local network or on the same computer, type nc <local IP of server (or localhost)> <port (default 9000>. Then, you can type stuff to send it, and type /nick <nickname> to set your nickname. You can connect with as many terminals as you want. You can also port-forward that port to be able to access the chat room outside of the local network.

Great!