Skip to content

Instantly share code, notes, and snippets.

@josephsdavid
josephsdavid / aoc1.jl
Last active December 2, 2022 01:50
advent of code day 1
read_input_string(s) = parse.(Int64, filter(!isempty, split.(split(s, "\n\n"))))
@info "1a" maximum(sum, read_input_string(read("input.txt")))
@info "1b" (sum ∘ x->last(x, 3))(sort(sum.(read_input_string(read("input.txt")))))
@josephsdavid
josephsdavid / startup.jl
Last active August 28, 2022 04:38
open vim in a server from julia repl
try
using Revise
catch
@info "Revise error!"
end
try
using OhMyREPL
colorscheme!("JuliaDefault")
enable_autocomplete_brackets(false)
@josephsdavid
josephsdavid / isochrone.py
Created August 18, 2022 03:30
isochrone.py
def isochrone(s):
return (lambda x,y : x == y)(* map(lambda f: len(f([x for x in s.lower() if s.isalpha()])), [set, lambda x: x]))
class Magic:
def __init__(self):
pass
magic = Magic()
def setmagic(f):
magic.__dict__[f.func_name] = f
@josephsdavid
josephsdavid / plot_server.bash
Last active June 17, 2022 17:38
python plot server
#!/usr/bin/env bash
# python3 -m pip install shis
kill=""
reload=""
clean=""
print_help() {
@josephsdavid
josephsdavid / init.lua
Created May 4, 2022 21:48
hammerspoon config
PaperWM = hs.loadSpoon("PaperWM")
SpoonInstall = hs.loadSpoon("SpoonInstall")
local function make_mod(mod)
local function ret(s)
return {mod, s}
end
return ret
end
@josephsdavid
josephsdavid / .style.yapf
Created February 23, 2022 06:29
yapf style
[style]
# Align closing bracket with visual indentation.
align_closing_bracket_with_visual_indent=False
# Allow dictionary keys to exist on multiple lines. For example:
#
# x = {
# ('this is the first element of a tuple',
# 'this is the second element of a tuple'):
# value,
@josephsdavid
josephsdavid / lua2norg.py
Last active January 30, 2022 08:07
takes lua docstrings or whatever and makes them norg
#!/usr/bin/env python3
import os
import sys
from collections import defaultdict, deque
from typing import List, Optional
def read_file(path: str) -> str:
if os.path.isfile(path):
with open(path, 'r') as f:
@josephsdavid
josephsdavid / pynorg.py
Created January 29, 2022 08:03
makes norg doc from python module
#!/usr/bin/env python3
import inspect
import re
import sys
from collections import deque
from typing import Any, List, Optional
class Doc(object):
@josephsdavid
josephsdavid / clickup.py
Created January 5, 2022 22:36
clickup backend WIP
from clickupython import client
import datetime
import itertools as it
import logging
from rich.logging import RichHandler
FORMAT = "%(message)s"
logging.basicConfig(
level="INFO", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()]
)