Skip to content

Instantly share code, notes, and snippets.

Avatar

Dalmo Mendonça dalmo3

View GitHub Profile
@dalmo3
dalmo3 / custom-toolbar.tsx
Last active Aug 19, 2021
React admin custom toolbar with redirect
View custom-toolbar.tsx
// 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 Jun 17, 2021
Download exceljs workbook from the browser
View downloadSheet.ts
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 Jul 22, 2020
Skype Web /Hangouts auto recall if unavailable
View skype-hangouts-recall.js
//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)
View parseTable.js
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 Mar 21, 2020
scrape departure and arrival data from airportia flight page
View airportia-times.js
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 Oct 23, 2019
Google Apps Script for fetching JSON from Coda
View Code.gs
// 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.