Skip to content

Instantly share code, notes, and snippets.

View PhilomathJ's full-sized avatar
💭
Building out my TypeScript chops on G-Suite

Jeremy Fairbanks PhilomathJ

💭
Building out my TypeScript chops on G-Suite
  • Boston, MA
  • X @PhilomathJ
View GitHub Profile
@PhilomathJ
PhilomathJ / interfaceToOptionalType.ts
Last active October 23, 2024 15:57
Typescript generic to modify every member of an interface without explicitly redefining each property. Useful in adhering to the DRY principle
// Generic type to apply to every property modifying it as needed
// In this case, we are making each property able to be undefined as well
type AllowUndefined<T> = { [K in keyof T]: T[K] | undefined }
// Initial interface
interface Interface {
a: number
b: string
}
@PhilomathJ
PhilomathJ / creality_ender_3_v2_end.gcode
Last active August 27, 2022 02:07
Ender 3 V2 Cura G-code
; Ender 3 Custom End g-code
M117 Completing printing sequence... ; Display message
M400 ; Finish Moves
G91 ; Set positioning to relative
G1 E-2 F2700 ; Retract the filament
G1 E-2 Z0.2 F2400 ; Retract the filament and raise Z-axis
G1 X5 Y5 F3000 ; Wipe
G1 Z10 ; Raise the Z-axis
G90 ; Set positioning to absolute
M106 S0 ; Turn-off fan
@PhilomathJ
PhilomathJ / markdown-details-collapsible.md
Created May 6, 2022 18:03 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@PhilomathJ
PhilomathJ / columnIndexToLetter.ts
Last active April 1, 2021 14:25
Converts a column index (in Excel or Google Sheets) to the letter equivalent
/**
* Recursively returns the letter combination corresponding to the column for the given index
* This is a more functional programming approach compared to the usual loop-based method
* Tested to column index out to one decillion
* @param {number} num Index to be converted
* @returns {string} Letter combination as column indicator
*/
const columnIndexToLetter = (num: number): string => {
return num <= 26
? String.fromCharCode((num === 0 ? 26 : num) + 64)
@PhilomathJ
PhilomathJ / lastColInRow.ts
Last active March 25, 2021 23:24
Returns the last populated row in a given column in a Google Spreadsheet
/**
* Returns the index of the last used row within the designated column
* @param {string} column Letter of the column to search
* @param {number} stopRow Optional row to stop searching on. This helps if there is additional populated rows below which are not to be counted
* @returns {number} Last populated row within the given range
**/
function lastRowInCol(column: string, stopRow: number = 0): number {
// Set lastRow to either the stopRow or the max row in the worksheet
let lastRow: number = stopRow == 0 ? SpreadsheetApp.getActiveSheet().getMaxRows() : stopRow;