Skip to content

Instantly share code, notes, and snippets.

View asmattic's full-sized avatar

Matt Oldfield asmattic

View GitHub Profile
@asmattic
asmattic / format-js-date.js
Created June 21, 2019 03:23
Format JavaScript date to common western string format (e.g. September 10, 2019)
// Date formatter function
function formatDateString(dateExecutionVar) {
var date = new Date(execution.getVariable(dateExecutionVar));
var monthList = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
var month = monthList[date.getMonth()];
var day = date.getDate().toString();
var year = date.getFullYear().toString();
@asmattic
asmattic / calculate-age.js
Last active June 20, 2019 18:46
Calculate Age
function getAge(DOB) {
var today = new Date();
var birthDate = new Date(DOB);
var age = today.getFullYear() - birthDate.getFullYear();
var m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age = age - 1;
}
return age;
@asmattic
asmattic / MarkdownTableConverter.js
Created July 11, 2018 04:50
CSV to Markdown Table Converter (React)
import React, { Component } from 'react';
import csvToMarkDownTable from 'csv-to-markdown-table';
const style = {
markdownTableWrapper: {
padding: '0',
margin: '0',
listStyle: 'none',
display: 'flex',
flexDirection: 'column',
@asmattic
asmattic / History\-12e74607\entries.json
Last active April 4, 2023 04:08
Visual Studio Code Settings Sync Gist
{"version":1,"resource":"file:///home/asmattic/Desktop/dev/asmattic/matt-oldfield-portfolio/public/manifest.webmanifest","entries":[{"id":"S9Dc.webmanifest","timestamp":1662583882074}]}
@asmattic
asmattic / external-links.js
Created October 24, 2017 17:07
Make all external links on the page open in new tabs