Skip to content

Instantly share code, notes, and snippets.

View asmattic's full-sized avatar

Matt Oldfield asmattic

View GitHub Profile
@asmattic
asmattic / export-outlook-contacts-outlook-365.md
Last active November 8, 2023 02:25
Export Contacts As CSV In Outlook 365

To export personal contacts, use this EWSContacts Credit: nestorisyynimaa

Here is a quickly built script to get users' contacts.

Before running the script you need to give impersonation rights to the user who runs the script:

Enable-OrganizationCustomization
@asmattic
asmattic / check-ubuntu-packup-progress.sh
Last active March 31, 2020 18:26
Check Ubuntu backup progress
pid=$(pgrep -n duplicity); if [ $pid ]; then fd=$( ps -o cmd --no-headers $pid | sed -E 's/.+(log-fd=[0-9]+).?/\1/' | cut -f2 -d =); if [ $fd ]; then cat /proc/$pid/fd/$fd; else echo "fd not found"; fi else echo "pid not found"; fi
@asmattic
asmattic / recursively-remove-node_modules-from-parent-directory.sh
Last active December 7, 2019 20:43
Recursively remove node_module directories from a parent folder
# SOURCE: https://rtmccormick.com/2018/01/10/clear-node-modules-folders-recursively-mac-linux/
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
# To recursively restore node_modules (DO NOT USE - STILL IN PROGRESS)
find . -name "package.json" -type f -prune -exec npm i '{}' +
@asmattic
asmattic / show-current-git-branch.sh
Last active March 31, 2020 18:26
Add the below line to your .bashrc or .bash_profile to have the current git branch show up in the terminal when in the project
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
@asmattic
asmattic / set-company-abbreviation.js
Created June 21, 2019 04:19
Set company abbreviation filtering out non-important words like in, and, or, etc.
function diff(a, b) {
var result = [];
for (var i = 0; i < a.length; i++) {
if (b.indexOf(a[i]) === -1) {
result.push(a[i]);
}
}
return result;
}
@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