Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
@primaryobjects
primaryobjects / helper.R
Created June 6, 2018 18:49
Using R to export all issues in JIRA to a tidy CSV dataset.
library(jira)
#' @name search_url
#' @title Get jira search url
#' @param jira_url base url to jira. Defaults to 'jira/'
#' @return string
#' @export
#' @examples
#' search_url()
search_url <- function(jira_url = getOption("jira_url")){
@primaryobjects
primaryobjects / parens.js
Created June 4, 2018 17:21
Determine matching parenthesis in a string. Solution using a stack.
var isValid = str => {
let result = true;
let stack = [];
for (let i=0; i<str.length; i++) {
const ch = str[i];
switch(ch) {
case '(':
case '[':
@primaryobjects
primaryobjects / windows10.md
Last active May 26, 2018 22:08
Windows 10 Upgrade Trouble Shooting due to Trend Micro Internet Security 2009

Windows 10 Update Trouble-Shooting

  • View the upgrade log in C:\$WINDOWS.~BT\Sources\Panther by viewing the most recently modified file ending with "_APPRAISER_HumanReadable.xml". For example: NRfRTVMqXU2NmA+M.1.30.1.2.61.3.12.0.0_APPRAISER_HumanReadable.xml

  • Delete the file for Trend Micro Internet Security 2009 at C:\Windows\SysWOW64\drivers\tmcomm.sys

inputs <- c('dbbaCEDbdAacCEAadcB', 'EbAAdbBEaBaaBBdAccbeebaec')
tally <- function(input) {
letters <- unlist(strsplit(input, ''))
hash <- new.env()
# Tally scores.
sapply(letters, function(letter) {
# If the letter is not uppercase it's a score. Otherwise, it's a loss.
score <- ifelse(gregexpr("[A-Z]", letter) < 1, 1, -1)
@primaryobjects
primaryobjects / digits.R
Last active April 26, 2018 18:29
[2018-04-23] Challenge #358 [Easy] Decipher The Seven Segments. Identify ASCII digits as their numerical values. https://www.reddit.com/r/dailyprogrammer/comments/8eger3/20180423_challenge_358_easy_decipher_the_seven/
#
# [2018-04-23] Challenge #358 [Easy] Decipher The Seven Segments
# https://www.reddit.com/r/dailyprogrammer/comments/8eger3/20180423_challenge_358_easy_decipher_the_seven/
#
# Demo at http://rextester.com/RINRE98737
#
# Kory Becker
# 4/26/2018
# http://primaryobjects.com
#
@primaryobjects
primaryobjects / sleep.js
Last active April 23, 2018 20:50
JavaScript sync sleep method with promisified await.
function sleep(timeout) {
return Promise(function(resolve) {
setTimeout(() => {
resolve();
}, timeout);
});
}
recaman <- function(n, s=c()) {
a <- 0
if (n > 0) {
val <- recaman(n - 1, s)
a <- val$a
s <- c(val$s, a)
an1 <- a - n
@primaryobjects
primaryobjects / goldbach.R
Last active April 13, 2018 19:31
[2018-04-11] Challenge #356 [Intermediate] Goldbach's Weak Conjecture. Find lists of prime numbers, less than the target, that sum to the target value. https://www.reddit.com/r/dailyprogrammer/comments/8bh8dh/20180411_challenge_356_intermediate_goldbachs/ Demo at http://rextester.com/RAQI17684
library(gtools)
is.prime <- function(num) {
if (num == 2) {
TRUE
} else if (any(num %% 2:(num-1) == 0)) {
FALSE
} else {
TRUE
}
@primaryobjects
primaryobjects / IntegerOptimizationPies.xlsx
Last active April 13, 2018 13:25
Integer Optimization, Linear Optimization, Linear Programming [2018-03-28] Challenge #355 [Intermediate] Possible Number of Pies https://www.reddit.com/r/dailyprogrammer/comments/87rz8c/20180328_challenge_355_intermediate_possible/
getEncoding <- function(letter1, letter2) {
# Find the number for each letter.
index1 <- match(letter1, letters)
index2 <- match(letter2, letters)
# Find the index number within the shifted letters by adding the two indices and taking the remainder from the number of letters.
index <- (index1 + index2 - 1) %% length(letters)
index <- ifelse(index == 0, 26, index)