Skip to content

Instantly share code, notes, and snippets.

View ashtonmeuser's full-sized avatar

Ashton Meuser ashtonmeuser

  • Dialpad
  • Vancouver, BC
View GitHub Profile
[alias]
lg = !"git lg1"
lg1 = log --graph --abbrev-commit --decorate --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
lg2 = log --graph --abbrev-commit --decorate --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lg3 = log --graph --abbrev-commit --decorate --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
@ashtonmeuser
ashtonmeuser / rxjs-two-way-bind.js
Last active November 14, 2018 22:42
RxJs BehaviorSubject for input element value
import { BehaviorSubject, fromEvent, timer } from 'rxjs';
import {
filter, distinctUntilChanged, shareReplay, tap, debounce, pluck
} from 'rxjs/operators';
const setValue = (element, value) => {
element.value = value; // eslint-disable-line no-param-reassign
};
const bindTextInput = (element) => { // Return BehaviorSubject of input text
const subject = new BehaviorSubject('');
@ashtonmeuser
ashtonmeuser / typeHelpers.js
Created November 22, 2018 19:08
Simple type checks
const isBoolean = b => typeof b === 'boolean';
const isNumber = n => typeof n === 'number' && !Number.isNaN(n);
const isObject = o => o !== null && typeof o === 'object';
const isString = s => typeof s === 'string';
@ashtonmeuser
ashtonmeuser / explode_dataframe_column.py
Created January 8, 2019 17:38
Explode rows of a Pandas dataframe on character
import pandas as pd
def explode_dataframe_column(df, target_column, separator=','):
"""
Explode target column on seperator
"""
row_accumulator = []
def splitListToRows(row, separator):
split_row = row[target_column].split(separator)
@ashtonmeuser
ashtonmeuser / auto-committer.sh
Last active March 14, 2019 02:42
Stage, commit, and push changed files in git repository
#!/bin/bash
usage() {
echo "Usage: $0 [-d <string>] [-u] [-r] [-h]" 1>&2
echo "-d Directory of target repository, defaults to working directory" 1>&2
echo "-u Consider untacked files" 1>&2
echo "-r Do not push to remote repository" 1>&2
echo "-h Show usage manual" 1>&2
exit 1
}
@ashtonmeuser
ashtonmeuser / wrapper.js
Created July 5, 2019 20:56
Execute or abandon function based on result of assertion function taking same arguments
const wrapper = (as, fn) => ((...args) => {
try {
as(...args);
} catch (error) {
return () => {};
}
return fn(...args);
});
@ashtonmeuser
ashtonmeuser / data-tooltip.css
Last active July 31, 2019 22:18
Add tooltips to elements with relevant data attribute
/* Relative positioning for tooltip-enabled elements */
[data-tooltip] {
position: relative;
cursor: pointer;
}
/* Attributes shared between tooltip content and triangle */
[data-tooltip]:before,
[data-tooltip]:after {
display: none; /* Hide tooltip by default */
background-color: #000;
class Modal {
constructor(message, timeout=3000) {
this.fadeTime = 500;
this.modalBackground = '#f00';
this.present(message);
this.removeTimer = setTimeout(this.remove.bind(this), timeout);
this.fadeTimer = setTimeout(this.fade.bind(this), timeout - this.fadeTime);
}
present(message) {
# Prompt
PROMPT='%{%F{red}%}♥%{%F{default}%} %1~ %# '
# Aliases
alias gitlg="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
# Misc.
export GREP_OPTIONS='--color=auto'
@ashtonmeuser
ashtonmeuser / count.js
Last active April 4, 2025 21:48
Example bookmarklets for bookmarkl.ink
//bookmarklet_title: Word Frequency
//bookmarklet_about: Display the top five most common words on a webpage. Drag the bookmarklet to your bookmarks bar to use it anywhere! If the word hippo shows up a lot, hippo should have a high occurrence (hippo hippo HIPPO).
var counts = { };
var text = document.body.innerText || document.body.textContent || '';
var words = text.split(/\b/).filter((word) => {
return word.match(/^\w+$/) !== null;
});
words.forEach((word) => {