Skip to content

Instantly share code, notes, and snippets.

View jmg-duarte's full-sized avatar
🤔

José Duarte jmg-duarte

🤔
View GitHub Profile
@jmg-duarte
jmg-duarte / colorset_to_accent.py
Created March 9, 2024 14:30
Extract a black/white accent for a .colorset/Contents.json color
import json
from typing import Any, Tuple
type RGB = Tuple[int, int, int]
type RGBA = Tuple[int, int, int, int]
def rgba_to_rgb(foreground: RGBA, background: RGB) -> RGB:
(fg_r, fg_g, fg_b, fg_a) = foreground
(bg_r, bg_g, bg_b) = background
@jmg-duarte
jmg-duarte / nhk.sh
Created October 27, 2023 16:30
NHK Episode Downloader
# Huge kudos to everyone working on yt-dlp, that's the heavylifting part
#
# The link points to Japanology+ but it should work with other series,
# maybe you'll need some adjustments to the jq query though
curl https://nwapi.nhk.jp/nhkworld/vodesdlist/v7b/program/japanologyplus/en/all/all.json |
jq -r ".data.episodes[].url" |
sed "s|^|https://www3.nhk.or.jp|" |
xargs -n 1 -P 2 yt-dlp
-- vim-plug
local Plug = vim.fn['plug#']
vim.call('plug#begin', '~/.config/nvim/plugged')
-- plenary provides utility functions for other plugins
-- think of it as a neovim plugin standard library
Plug('nvim-lua/plenary.nvim')
-- fuzzy finder file browser
Plug('nvim-telescope/telescope.nvim')
@jmg-duarte
jmg-duarte / parse_quote_dbg.rs
Last active May 6, 2023 19:10
Yandros parse_quote! debug
// Credits: Yandros#4299
macro_rules! parse_quote {(
$($code:tt)*
) => ({
eprintln!("[{}:{}:{}] parse_quote! {{ {} }}", file!(), line!(), column!(), quote!( $($code)* ));
::syn::parse_quote!( $($code)* )
})}
macro_rules! parse_quote {(

Keybase proof

I hereby claim:

  • I am jmg-duarte on github.
  • I am jmgduarte (https://keybase.io/jmgduarte) on keybase.
  • I have a public key ASCzSL2zUTqYGDlKA8Pe2l-tQn58IYUaOE6ni1WJZVUIhQo

To claim this, I am signing this object:

@jmg-duarte
jmg-duarte / starship.toml
Last active June 14, 2023 13:07
starship.toml
# add_newline = false
format="""\
$directory\
$package\
$git_branch\
$line_break\
$hostname\
$character\
"""
font_family Jetbrains Mono
bold_font Jetbrains Mono Bold
italic_font Jetbrains Mono Italic
bold_italic_font Jetbrains Mono Medium Italic
font_size 9.0
window_padding_width 10
initial_window_height 1280
@jmg-duarte
jmg-duarte / ocv-setup.sh
Created September 4, 2020 11:11
Setup OpenCV with an Anaconda environment
#!/bin/bash
function install_dependencies {
echo "installing dependencies"
sudo apt update
sudo apt install -y \
build-essential \
cmake \
git \
libgtk2.0-dev \
# Colors (Monokai Pro)
colors:
# Default colors
primary:
background: '#2D2A2E'
foreground: '#FCFCFA'
# Normal colors
normal:
black: '#403E41'
def hash(v, size):
return abs(v) % size
def simple_zero_sum(arr):
_hash = lambda v: abs(v) % len(arr)
changes = 1
while changes > 0:
changes = 0
for idx, value in enumerate(arr):