Skip to content

Instantly share code, notes, and snippets.

View SeanMcGrath's full-sized avatar

Sean McGrath SeanMcGrath

View GitHub Profile
@SeanMcGrath
SeanMcGrath / useTilled.ts
Created December 22, 2022 16:45
React hook for tilled.js
import React from "react";
const scriptId = "tilled-js";
/**
* Load and expose the tilled.js PCI-compliant payment capture utility.
* https://api.tilled.com/docs#section/Tilled.js
*/
const useTilled = () => {
const [tilled, setTilled] = React.useState<any>(undefined);
@SeanMcGrath
SeanMcGrath / poshmark-share
Last active October 14, 2024 01:41
JS code to share all items in a poshmark closet to followers and all available events
const clickDelta = 4000; // ms delay between clicks
const cycleDelta = clickDelta * 100; // ms delay between share cycles
const clickLinks = (el) => {
el.click();
// set a short timeout so there's time to load in the active parties/render the modal
setTimeout(() => {
document
.querySelectorAll("[data-et-name='share_poshmark']")
@SeanMcGrath
SeanMcGrath / wiki-install
Created August 12, 2016 14:52
one-liner to install wiki
sudo curl https://gist.githubusercontent.com/SeanMcGrath/492e80cbd74126dd880c14e51e4509e8/raw/a55975ad3c6fd215a7fd33d17e14effd5e3b460f/wiki >! /usr/local/bin/wiki && chmod +x /usr/local/bin/wiki && brew install chrome-cli && echo 'wiki installed! run wiki -h to see usage instructions'
@SeanMcGrath
SeanMcGrath / wiki
Last active August 12, 2016 14:30
relmail + chrome == magic
#!/bin/bash
# sean mcgrath - [email protected]
usage () {
echo 'usage: wiki [-hs] [-m MESSAGE] [# of commits]'
echo ' -h show this help'
echo ' -s suppress Jira ticket message from appearing in post header'
echo ' -m replace Jira ticket message with MESSAGE'
echo ''
echo ' Automagically parses your relmail and prepares it for wiki submission.'
@SeanMcGrath
SeanMcGrath / ticket
Last active August 9, 2016 19:08
Use chrome-cli to find first open jira ticket and format it for git commit
#!/bin/bash
JIRA_TABS=`chrome-cli list tabs | grep 'ENG.*Jira' | cut -d ' ' -f 1 | sed -e 's/\[//g' -e 's/\]//g'`
for tab in $JIRA_TABS; do
chrome-cli execute '(function() { return document.getElementById("key-val").textContent + " " + document.getElementById("summary-val").textContent; })();' -t $tab
done
@SeanMcGrath
SeanMcGrath / scan_waveform.c
Created January 7, 2016 19:05
Root Waveform Readout for fADC125
#define scan_waveform_cxx
// The class definition in scan_waveform.h has been generated automatically
// by the ROOT utility TTree::MakeSelector(). This class is derived
// from the ROOT class TSelector. For more information on the TSelector
// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
// The following methods are defined in this file:
// Begin(): called every time a loop on the tree starts,
// a convenient place to create your histograms.
// SlaveBegin(): called after Begin(), when on PROOF called only on the
@SeanMcGrath
SeanMcGrath / matrixRMS
Created April 8, 2015 14:16
Calculate the RMS deviation between the values in 2 distance matrices computed by Gaussian and parsed by matrixparse.
#!/usr/bin/env python
import argparse, sys, csv, math
def calcRMS(reader1, reader2):
def makeList(reader):
l = []
for row in reader:
for val in row:
@SeanMcGrath
SeanMcGrath / matrixparse
Created April 6, 2015 20:41
Create a .csv file containing the distance matrix of an optimized molecule from a Gaussian output file.
#!/usr/bin/env bash
# Generates a standardized table of bond lengths and bond angles
# from a gaussian .log file.
if [[ $# > 0 ]]
then
# Find distance Matrix
awk '/^ *1 *2 *3 *4 *5 *$/ {p=1}; p; /Stoich/ {p=0}' $1 |
# Extract lines with distance data
egrep '^[ \t]*[0-9]+[ \t]*[A-Z][ \t]*([-+]?[0-9]*\.?[0-9]+[ \t]*)' |
@SeanMcGrath
SeanMcGrath / ramanparse
Created April 6, 2015 20:05
Creates a .csv file of computed Raman intensities and frequencies from a Gaussian output file.
#!/usr/bin/env bash
# generates comma-separated list of raman frequencies and intensities from
# Gaussian output file.
if [[ $# > 0 ]]
then
egrep '(Frequencies|^ Raman )' $1 | awk '
{
if ( $1 == "Frequencies"){
a = $3