Skip to content

Instantly share code, notes, and snippets.

View abrahamjuliot's full-sized avatar
Focusing

Abraham abrahamjuliot

Focusing
View GitHub Profile
@abrahamjuliot
abrahamjuliot / workaholics.gs
Last active August 1, 2021 22:43
silence unread workaholics - gmail API
// https://stackoverflow.com/a/63964522
// requires Gmail API
const getLabelMap = () => {
const allLabels = Gmail.Users.Labels.list('me')
const labelMap = allLabels.labels.reduce((acc, label) => {
acc[label.name] = label.id
return acc
}, {})
return labelMap
}
@abrahamjuliot
abrahamjuliot / gmail.txt
Last active June 21, 2021 17:46
hybrid plain text gmail messages via uBlock Origin
! hybrid plain text gmail messages
! block images
||gm1.ggpht.com/$image,domain=mail.google.com,important
mail.google.com##img.CToWUd
!mail.google.com##.editable img
! remove blockquote nesting
mail.google.com##[data-message-id^="#msg"] blockquote:style(padding:0!important;margin: 0!important;border: none!important;)
!mail.google.com##.editable blockquote:style(padding:0!important;margin: 0!important;border: none!important;)
@abrahamjuliot
abrahamjuliot / webgl.js
Last active September 19, 2023 20:55
webgl fingerprint
// Based on and inspired by https://github.com/CesiumGS/webglreport
// https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants
const WebGLConstants = [
'ALIASED_LINE_WIDTH_RANGE',
'ALIASED_POINT_SIZE_RANGE',
'ALPHA_BITS',
'BLUE_BITS',
'DEPTH_BITS',
'GREEN_BITS',
@abrahamjuliot
abrahamjuliot / notifyDriver.gs
Created February 25, 2020 20:17
Notify EPS drivers
function locale(x) { return Utilities.formatDate(new Date(x), 'PST', 'EEE MMM d, yyyy') }
function constants() {
return {
spreadsheetId: '1RTKJTvzfst_ZVQHUyEy2PnB4P075verlDJLKMgb0UFU',
sheetId: 16057777,
startRow: 2,
startCol: { letter: 'A', num: 1 },
endCol: { letter: 'E', num: 5 }
}
@abrahamjuliot
abrahamjuliot / diffChecker.gs
Last active February 19, 2020 20:21
Email Spreadsheet Revision Changes
function getFolderId() { return '[Your Drive Folder Id]' /*Keys/Directory Review*/ }
function flatten(arr) { return [].concat.apply([], arr) }
function diffs(str1, str2, color) {
let diffs = [], arr1 = str1.replace(/\n/, '').split('\t').join(' ').split(' ')
const arr2 = str2.replace(/\n/, '').split('\t').join(' ').split(' ')
arr1.forEach((val, i) => val != arr2[i] && diffs.push(val))
diffs.forEach(val => arr1[arr1.indexOf(val)] = `<span style="background:${color}">${val}</span>`)
return arr1.join(' ')+'\n'
@abrahamjuliot
abrahamjuliot / unread.gs
Created February 10, 2020 22:57
Log unread gmail messages
function logToTextFile(filename, content) {
var files = DriveApp.getFilesByName(filename)
if (files.hasNext()) { return files.next().setContent(content) }
else { return DriveApp.createFile(filename, content) }
}
function getUnread() {
function flatten(arr) { return [].concat.apply([], arr) }
function formatDate(d) { return Utilities.formatDate(new Date(d), "PST", "EEE, MMM d @h:mm a")}
function removeDomain(strongWithEmail) { return strongWithEmail.replace(/<.+@.+>/gm, '')}
@abrahamjuliot
abrahamjuliot / code.gs
Last active October 31, 2019 16:53
Log on edit
function onEdit(e){
var sheetName = 'Daily Log'
var activeSheet = e.source.getActiveSheet()
if (activeSheet.getName() == sheetName) {
var seconds = 1000
var row1 = 2
var signCol = 4
var whenSigned = SpreadsheetApp.newFilterCriteria().setHiddenValues(['TRUE']).build()
@abrahamjuliot
abrahamjuliot / routes.js
Last active March 1, 2018 17:30
Functional Switch in Javascript
const callIfFunction = x => x instanceof Function ? x() : x
const choose = switchFn => // cache cases
caseVal => callIfFunction(switchFn(caseVal)[caseVal] || switchFn().default) // get case
const agree = (x, ...list) => // agree on a fall through set
list.find(val => x === val) || list[0]
// make as many of these as needed
const colors = choice => ({
@abrahamjuliot
abrahamjuliot / fp101.js
Last active January 26, 2021 17:57
Functional Programming 101
//Immutable state:
const state = Object.freeze({ })
//Pure functions:
const fn = (val, dependencies = [ ]) => val+1
//Higher-order functions:
const decorate = (x, fn) => {
return fn(x)
}
@abrahamjuliot
abrahamjuliot / faculty-template.pug
Last active September 11, 2017 21:31
Pug/Mustache Faculty Template
//--------------Variables-------------
-
first = '',
last = '',
position = '',
office = '',
phone = '',
websiteURL = '',
invite = '',
degrees = [