Skip to content

Instantly share code, notes, and snippets.

View dalmo3's full-sized avatar

Dalmo Mendonça dalmo3

View GitHub Profile
@dalmo3
dalmo3 / git-prune.sh
Last active September 6, 2023 02:54
git prune
# https://stackoverflow.com/questions/13064613/how-to-prune-local-tracking-branches-that-do-not-exist-on-remote-anymore
# remove local orphan branches
git fetch --prune
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
# remove local merged branches
git branch --merged main | grep -v '^[ *]*main$' | xargs git branch -d
@dalmo3
dalmo3 / custom-toolbar.tsx
Last active August 19, 2021 03:23
React admin custom toolbar with redirect
// add a custom toolbar prop to both CommentEdit and CommentCreate
// don't use redirect prop!
<SimpleForm toolbar={<CommentFormToolbar/>}>
// defined as
const CommentFormToolbar: VFC<ToolbarProps> = (props) => {
const { post_id } = useRecordContext();
return (
@dalmo3
dalmo3 / downloadSheet.ts
Created June 17, 2021 10:36
Download exceljs workbook from the browser
export const downloadSheet = (workbook: ExcelJS.Workbook) => {
workbook.xlsx
.writeBuffer()
.then((buffer) => {
// buffer --> blob
const blob = new Blob([buffer], { type: 'application/vnd.ms-excel' });
const link = document.createElement('a');
link.download = 'download.xlsx';
link.target = 'blank';
@dalmo3
dalmo3 / skype-hangouts-recall.js
Last active July 22, 2020 22:52
Skype Web /Hangouts auto recall if unavailable
//Skype
//on the call screen
let title="Audio Call"
document.querySelector(`[title=${title}]`).click();
let i2 = setInterval(() => {
console.log('trying...')
let b = document.querySelector(`[title=${title}]`).click();
b && b.click();
},1000)
let arr = []
document.querySelectorAll('table.table-style-two tbody tr').forEach(row => {
let [ case_number, location, age_bracket, gender, info ] = row.innerText.split('\t')
let obj = {
id: case_number,
case_number,
status: '',
date_confirmed: '',
date_suspected: '',
location_history: [
@dalmo3
dalmo3 / airportia-times.js
Created March 21, 2020 07:30
scrape departure and arrival data from airportia flight page
document.querySelectorAll('.flightInfo-schedule').forEach(s =>{
let f = s.querySelector('.flightInfo-date');
s.querySelectorAll('.flightInfo-dateItem').forEach(d=>{
let l = d.querySelector('.flightInfo-dateLabel');
if (l && l.innerText === 'Actual:') {
let t = d.querySelector('.flightInfo-dateTime');
console.log(f.innerText, t.innerText)
}})
})
@dalmo3
dalmo3 / Code.gs
Last active May 28, 2022 01:02
Google Apps Script for fetching JSON from Coda
// CodaAPI reference: https://script.google.com/macros/library/d/15IQuWOk8MqT50FDWomh57UqWGH23gjsWVWYFms3ton6L-UHmefYHS9Vl/5
// CodaAPI source: https://script.google.com/d/15IQuWOk8MqT50FDWomh57UqWGH23gjsWVWYFms3ton6L-UHmefYHS9Vl/edit
// Setup and global variables
// first, generate an API token at https://coda.io/account
// then define apiKey at File > Project Properties > Script
var apiKey = PropertiesService.getScriptProperties().getProperty('apiKey');
//Logger.log(apiKey);
CodaAPI.authenticate(apiKey); // Replace with your token.