Skip to content

Instantly share code, notes, and snippets.

View BobToninho's full-sized avatar
🐘

Roberto Tonino BobToninho

🐘
View GitHub Profile
# huge inspiration from https://scriptingosx.com/2019/07/moving-to-zsh-06-customizing-the-zsh-prompt/
export PROMPT='%(?.%F{green}√.%F{red}?%?)%f %B%F{blue}%1~%f%b %(!.#.❯) '
function gch {
BRANCH=$(git branch | fzf --cycle | tr -d '[:space:]')
if [[ $BRANCH =~ '^\*' ]] then
echo "current branch selected, nothing to do"
return 0
fi
if [[ -n $BRANCH ]] then
git checkout $BRANCH
function navigate-projects {
cd $(fd . ~/dev/ --maxdepth 1 --type d | fzf --cycle)
}
alias np="navigate-projects"
@BobToninho
BobToninho / dont-initialize-until-accessed.ts
Created July 23, 2023 14:52
Make an object that will pretend to be a pool but not initialize itself until someone tries to access a property on it
// Shamelessly stolen from https://github.com/vercel/storage/blob/6104c9fa9731b9610d9e4e8b68652b27d355b0ba/packages/postgres/src/index.ts
import type { QueryResult, QueryResultRow } from '@neondatabase/serverless';
import { type VercelPool, createPool } from './create-pool';
import type { Primitive } from './sql-template';
export * from './create-client';
export * from './create-pool';
export * from './types';
export { postgresConnectionString } from './postgres-connection-string';
@BobToninho
BobToninho / convertFonts.js
Created June 29, 2023 09:40
Google Docs: Replace paragraphs' fonts with a new font
const IS_DRY_RUN = false
const FONTS_TO_REPLACE = ['Arial', 'Times New Roman']
const REPLACING_FONT = 'Helvetica Neue'
function convertFonts() {
const doc = DocumentApp.getActiveDocument();
const body = doc.getBody();
const paragraphs = body.getParagraphs();
@BobToninho
BobToninho / md-to-odt.nu
Created June 26, 2023 10:58
Define an utility function for converting markdown files to odt together with the script to use it
ls *.md | each { |it| $it.name | parse '{file_name}.{extension}' | get file_name } | flatten | each { |it| to-odt $it }
@BobToninho
BobToninho / git-pretty-log.txt
Created May 16, 2023 16:37
Git log with hashes and dates
git log --format="%Cgreen%h %Creset| %Cblue%cs %Creset| %s"
@BobToninho
BobToninho / powerapps-gather-tables-with-read-permissions.txt
Last active April 26, 2023 09:50
Gather tables with read permission in PowerApps
// Resets the Collection
Clear(colTableList);;
If(
DataSourceInfo(
'Table To Check';
DataSourceInfo.ReadPermission
);
Collect(
colTableList;
{
@BobToninho
BobToninho / powerapps-check-user-in-group.txt
Created April 26, 2023 08:50
Check if user is in a group in PowerApps
// Note: GruppidiOffice365 will vary according to your PowerApps UI language. Yes, it's ugly
Set(
varIsInGroup;
User().Email in GruppidiOffice365.ListGroupMembers("GROUP_ID").value.userPrincipalName ||
User().Email in GruppidiOffice365.ListGroupMembers("GROUP_ID").value.mail
);;
@BobToninho
BobToninho / machine.js
Created March 25, 2022 10:41
Generated by XState Viz: https://xstate.js.org/viz
const accordionsMachine = Machine({
id: "list-element-accordions",
initial: "closed",
states: {
closed: {
on: {
OPEN_LIST_ELEMENT: {
target: "path-accordions",
},
},