Skip to content

Instantly share code, notes, and snippets.

View tylerpeterson's full-sized avatar

Tyler Peterson tylerpeterson

  • FamilySearch
  • West Valley City, Utah, United States
View GitHub Profile
@tylerpeterson
tylerpeterson / filterTopJson.js
Created June 17, 2020 23:28
Turning interactive Splunk results with Agent strings into a nice CSV file
#!/usr/bin/env node
// https://stackoverflow.com/questions/45854169/how-can-i-use-an-es6-import-in-node
// That's why this package.json says where in a module
// Use Bowser to interpret the agent strings
// Seems to give results comparable to https://developers.whatismybrowser.com/useragents/parse/#parse-useragent
// https://www.npmjs.com/package/bowser
// https://lancedikson.github.io/bowser/docs/
import Bowser from "bowser"
@tylerpeterson
tylerpeterson / 2018-09-27-count-3-beginning.markdown
Created September 27, 2018 15:44
2018-09-27 Count 3 Beginning
@tylerpeterson
tylerpeterson / 2017-06-15-08-47-11-sample.markdown
Created September 27, 2018 15:42
2017-06-15-08-47-11 sample
@tylerpeterson
tylerpeterson / hate_words.txt
Last active September 20, 2018 16:38
A list of words often used when the speaker is very upset and possibly violating reasonable rules of courtesy. This is not hate speech, as in the crime. It's just named hate words because hate is one of those words that well represents this group.
hate
ridiculous
@tylerpeterson
tylerpeterson / New Draft in Outlook.AppleScript
Created September 21, 2015 21:18
Making a new email in Outlook 365 via AppleScript
set the_file_name to "test.txt"
set the_file to alias ((path to desktop as text) & the_file_name)
tell application "Microsoft Outlook"
set new_message to make new outgoing message at mail folder "Cabinet" with properties ¬
{subject:"Test Subject", content:"Here is some test content. See attached: " & the_file_name}
make new attachment at end of new_message with properties {file:the_file}
make new recipient at new_message with properties {type:to recipient type, email address:{name:"Tyler Peterson", address:"[email protected]"}}
make new recipient at beginning of new_message with properties {type:cc recipient type, email address:{name:"CC Tyler", address:"[email protected]"}}
make new recipient at beginning of new_message with properties {type:bcc recipient type, email address:{name:"BCC Tyler", address:"[email protected]"}}
end tell
@tylerpeterson
tylerpeterson / index.js
Created September 15, 2015 19:15
Example of searching github for code hits and then contributor information
#!/usr/bin/env node
// Be sure to chmod +x this file if you want to run it by name
// Node requires
var util = require('util');
// Vendor requires
var request = require('superagent');
var debug = require('debug')('blueprint-maint');
@tylerpeterson
tylerpeterson / base64-demo.js
Created September 15, 2015 03:08
Node Base64
#!/usr/local/env node
new Buffer('payload').toString('base64'); // 'cGF5bG9hZA=='
new Buffer('cGF5bG9hZA==', 'base64').toString('ascii'); // 'payload'
@tylerpeterson
tylerpeterson / compile
Created June 8, 2014 00:04
A couple of files to help explore error-swallowing in bash pipelines.
#!/usr/bin/env bash -eux -o pipefail
#set -eux
indent() {
echo "status? $?"
sed -e 's/^/ /'
}
#[ -f "./deploy" ] && ( set -o pipefail; ./deploy | indent ) && exit 0
@tylerpeterson
tylerpeterson / giga.js
Created June 8, 2014 00:01
My unpolished solution to a couple of the questions from the Bloomberg coding challenge at JSConf 2014. Seems safe to share now.
//Problem : Giga Ball
//Language : Javascript
//Compiled Using : V8
//Version : Node 0.10.25
//Input for your program will be provided from STDIN
//Print out all output from your program to STDOUT
/**
* My unpolished solution to the Giga Ball question from the Bloomberg coding challenge at JSConf 2014.
* ~Tyler
@tylerpeterson
tylerpeterson / numbersIsoWeekFormula.txt
Last active December 25, 2015 05:39
Numbers formula for computing the iso week number for a date.
-- This formula assumes that the date is stored in A1
=QUOTIENT(DATEDIF(DATE(YEAR(A1 - WEEKDAY(A1,3)+3),1,1)-WEEKDAY(DATE(YEAR(A1-WEEKDAY(A1,3)+3),1,1),3),A1,"D"),7)+IF(WEEKDAY(DATE(YEAR(A1 - WEEKDAY(A1,3) + 3),1,1),2)>4,0,1)
-- Another, commented version of the formula:
-- The key trick of this formula is using thursday of the week the date falls in to determine which
-- ISO year we will fall into. Many thanks to Jürgen Schell for this idea:
-- http://www.j-schell.de/applescript_calendar_weeks_iso