Skip to content

Instantly share code, notes, and snippets.

@ayoayco
ayoayco / gh-alerts.md
Created December 14, 2023 12:16
GH Alerts in MD files

Note

Highlights information that users should take into account, even when skimming.

Tip

Optional information to help a user be more successful.

Important

Crucial information necessary for users to succeed.

[!WARNING]

/**
* A typeguard to check if a value is valid entry in an Enum.
* If it passes, the value will be typed as the enum
* @param value value to check
* @param enumType Enum to check against
* @returns boolean and assigns type to value
* @example
* ```ts
* enum TestEnum {
* Value1 = 'Value1',
@ayoayco
ayoayco / freeze-object.js
Last active August 5, 2023 04:45
Type-checking vanilla JS with JSdoc and the TS typechecker
// @ts-check
/**
* @typedef {string | number | boolean | null | undefined} Primitive
*/
/**
* @template { Primitive } T
* @template {T | Record.<string,T>} R
* @param {R} v
@ayoayco
ayoayco / install-vundle.txt
Created July 15, 2023 16:29
install vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
#!/bin/bash
while IFS="," read -r user boosts notify lang
do
echo "refreshing $user..."
RAILS_ENV=production /home/mastodon/live/bin/tootctl accounts refresh $user
done < <(tail -n +2 following.csv)
#!/bin/bash
# Delete all cached headers
rm -rf /home/mastodon/live/public/system/cache/accounts/headers/*
# Prune remote accounts that never interacted with a local user
RAILS_ENV=production /home/mastodon/live/bin/tootctl accounts prune;
# Remove remote statuses that local users never interacted with older than n days
RAILS_ENV=production /home/mastodon/live/bin/tootctl statuses remove --days 7;
@ayoayco
ayoayco / Counter.tsx
Created April 19, 2023 06:40
Counter component
import { useState } from 'react'
const Counter = () => {
const [state, setState] = useState(0)
return (
<>
<h1>Counter</h1>
<p>{state}</p>
<button onClick={() => setState(state + 1)}>+</button>
@ayoayco
ayoayco / gist:406c1c968a5f2fe0ca87081d1337fd65
Created November 10, 2022 19:33
delete all vim temp files recursively
find . -type f -name '*~' -delete
@ayoayco
ayoayco / GitCommitEmoji.md
Created August 28, 2022 17:50 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
@ayoayco
ayoayco / update-commit-author.bat
Created November 4, 2021 05:10
Update Commits Author Email
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "mail@ayco.io" ];
then
GIT_AUTHOR_EMAIL="ramon.aycojr@gmail.com";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD