Skip to content

Instantly share code, notes, and snippets.

View diogotito's full-sized avatar

Diogo Tito Victor Marques diogotito

View GitHub Profile
[core]
autocrlf = input
eol = lf
editor = vim
pager = delta
[push]
autoSetupRemote = true
[pull]
rebase = true
[merge]
@diogotito
diogotito / init.lua
Last active July 16, 2024 11:31
Minimal Neovim init.lua
--[[
I'm actually interested in moving to Lazyvim if I am ever to adopt Neovim as my main development editor.
This is just for some light editing sesions in the terminal
--]]
-- Don't load Vim plugins installed with pacman
vim.opt.rtp:remove('/usr/share/vim/vimfiles')
-- Gosh I can't unlearn this habit!
local cursed_esc = 'jk'
@diogotito
diogotito / Code.gs
Created July 10, 2024 18:40
Adds the label "newsletters" to any Gmail thread that has any label under it (like "newsletters/blogs")
function fixNewsletterLabels() {
const LABEL_NAME = PropertiesService.getScriptProperties().getProperty('root label') ?? "newsletters"
let rootLabel = GmailApp.getUserLabelByName(LABEL_NAME)
// Get the "newsletters" label and all labels under it
let newsLabelsNames = GmailApp.getUserLabels()
.map(label => label.getName())
.filter(labelName => labelName.startsWith(LABEL_NAME + "/"));
let query = "-label:newsletters ";
@diogotito
diogotito / Microsoft.PowerShell_profile.ps1
Created June 27, 2024 18:14
PowerShell core (pwsh) $profile with some manual profiling of modules and initialisation steps
# Write-Host -ForegroundColor Green 'Measuring...'
$stopWatch = [System.Diagnostics.Stopwatch]::new()
$stopWatch.Start()
[System.Collections.ArrayList] $stops = @()
[double] $last = 0.0
function stop($descr) {
$t = $stopWatch.Elapsed.TotalMilliseconds
$d = $t - $last
[void] $stops.Add([PSCustomObject]@{
Accumulated = "`e[36m$t`e[0m"
@diogotito
diogotito / Default (Windows).sublime-keymap
Last active June 25, 2024 14:33
Sublime LiteVintageous
[
// -------------------------------------------------------------------------------------------
// Text editing tweaks
{ "keys": ["alt+j"], "command": "swap_line_down"},
{ "keys": ["alt+k"], "command": "swap_line_up"},
// * Emacs-like paragraph selection
{ "keys": ["alt+h"], "command": "expand_selection_to_paragraph", "args": {"markup_aware": true}},
{ "keys": ["alt+shift+h"], "command": "expand_selection_to_paragraph", "args": {"markup_aware": true}},
local function abcdefu(a, b, c, d, e, ...)
print(a)
print(b)
print(c)
print(d)
print(e)
print(...)
return "yay"
end
@diogotito
diogotito / paste_in_console.js
Created June 12, 2024 11:34
Testing requestAnimationFrame timings with `progress` as a live expression, ES6 Map and console.table
{
const SAMPLES = 1000
progressObj = {
p: 0,
target: SAMPLES,
bars: 10,
toString() {
if (this.p < this.target) {
let progressBar = [...Array(this.bars)].map((_, bar) => ((this.p) / this.target) > ((bar + 1) / this.bars) ? '#' : '.').join('')
let percent = ((this.p) / SAMPLES * 100).toFixed(2) + "%"
@diogotito
diogotito / keybindings.json
Last active April 17, 2024 16:45
VSCode keybindings and settings
// Place your key bindings in this file to override the defaultsauto[]
[
// ===== Vim ===== MARK:vim
// ---- <Alt-[eafbhjkl]> to move the cursor in Insert mode like MARK:vim-rsi
{
"key": "Alt+e",
"command": "vim.remap",
"when": "inputFocus && vim.mode == 'Insert'",
"args": {
"after": [
@diogotito
diogotito / Microsoft.PowerShell_profile.ps1
Created January 17, 2024 19:37
Powershell utility functions in $profile to easily colorize things in Calculated Properties (for Select-Object, Format-Table, etc.)
# aux
# ---------------------
enum CC { RESET = 0; RED = 31; GREEN; YELLOW; BLUE; MAGENTA; CYAN; GRAY }
function CCs() { [enum]::GetValues([CC]) | select -skip 1 | % { [pscustomobject]@{ Code = +$_; Name = (f $_ "$_") } } }
function Get-ColoredString($color, [string] $text) {
if ($Host.UI.SupportsVirtualTerminal) {
[char] $ESC = 27
[int] $code = $color -as [CC]
"$ESC[${code}m" + $text + "$ESC[0m"
@diogotito
diogotito / jq.md
Last active October 23, 2023 22:31
[pt] Apontamentos jq

jq

Created segunda-feira 28 junho 2021 @cheatsheet

Flags úteis

  • -s (slurp) "sorve" um fluxo de vários documentos JSON (AKA "JSON Lines") para uma array. O filtro só recebe esta array.
  • -r (raw) Se o meu filtro produzir uma stream de strings, isto tira as aspas no output. Útil para passar para outros comandos.