Skip to content

Instantly share code, notes, and snippets.

View shaun-jacks's full-sized avatar

Shaun Jackson shaun-jacks

  • Software Engineer, Sony Playstation
  • San Diego, CA
View GitHub Profile
@shaun-jacks
shaun-jacks / advent-of-code-2021-day5.ts
Created December 5, 2021 07:25
Advent of Code 2021 Day 5 Solution - Typescript
import * as fs from 'fs'
import * as path from 'path'
class Input {
buffer: Buffer | undefined;
parsed: number[][][] | undefined
readBuffer() {
this.buffer = fs.readFileSync(path.join(process.cwd(), 'day5', 'input', 'input.txt'))
}
parseBuffer() {
@shaun-jacks
shaun-jacks / advent-of-code-day4-part2.ts
Created December 4, 2021 08:48
Advent of Code 2021 Day 4 Part 2 - RXJS solution
import * as fs from 'fs'
import * as path from 'path'
import * as process from 'process'
const inputDir = path.join(process.cwd(), 'day4', 'input');
import { BehaviorSubject, combineLatest, concatMap, Observable, Subject } from 'rxjs'
function parseDraws(): number[] {
const drawsString = fs.readFileSync(path.join(inputDir, 'random_numbers.txt'), 'utf-8').toString();
return drawsString.split(",").map(num => parseInt(num, 10))
}
@shaun-jacks
shaun-jacks / color_cell_renderer_rhandsontable.R
Created March 12, 2019 05:03
Function to color cells in rhandsontable along with code to use it
# This generates a string that will be used within the render fxn
# in handsontable(). The string needs two parameters for this fxn to work:
# 1. A list of columns: so a list named col_highlight, with keys:
# colhighlight1, colhighlight2 ... up to vars_len. Each key has a corresponding
# value which is the column number within the handsontable to color
# 1. A list of lists of rows: so a list named row_highlight, with keys:
# rowhighlight1, row_highlight2 ... up to vars_len. Each key has a corresponding
# value which is a vector of row numbers within the handsontable to color
# The highlighted cells are the cells represented by colhighight1, rowhighlight1,...
@shaun-jacks
shaun-jacks / face_detection_output.md
Created February 22, 2019 04:46
Cloud Vision relevant face detection output
values$img_res
|
|____$fdBoundingPoly
|      |
|      |_____$vertices
|             |_____[[1]] # face 1
|                   |_______$x:   [[1]] [[2]] [[3]] [[4]]
|                   |       |____1285, 2322, 2322, 1285
| |
@shaun-jacks
shaun-jacks / shiny-vision-reset-button.R
Created February 21, 2019 00:21
example of reset button in shiny vision project
# on click of restart button, reset all reactive values
observeEvent(input$reset, {
values$img_res = NULL
values$file_path = ""
photo = NULL
values$analysis_type = ""
values$analysis_selected = F
values$warning_inputs = ""
values$file_uploaded = F
values$upload_step = 1
@shaun-jacks
shaun-jacks / shiny-vision-datatable-code-server.R
Created February 21, 2019 00:14
Code for renderDataTable outputting the results from Google Cloud Vision within R Shiny app
#### Analysis Table ####
output$results <- DT::renderDataTable({
if (values$analysis_type == "FACE_DETECTION") {
as.data.frame(
list(
joy = values$img_res$joyLikelihood,
sorrow = values$img_res$sorrowLikelihood,
anger = values$img_res$angerLikelihood,
surprise = values$img_res$surpriseLikelihood
)
@shaun-jacks
shaun-jacks / results_from_GCV.csv
Created February 21, 2019 00:07
parsed resuls to use within GCV
feature column names to use
FACE_DETECTION joyLikelihood; sorrowLikelihood; angerLikelihood; surpriseLikelihood
OBJECT_LOCALIZATION name; score
LANDMARK_DETECTION description; score
LABEL_DETECTION description; score; topicality
TEXT_DETECTION locale; description
LOGO_DETECTION description; score
@shaun-jacks
shaun-jacks / shiny-dashboard-example-app.R
Created February 18, 2019 20:01
Shiny Dashboard Example using code from shiny dashboard website Tutorial
## app.R ##
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
## Sidebar content
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
@shaun-jacks
shaun-jacks / shiny-vision-server-stage-2-ui.R
Created February 18, 2019 06:41
UI code for stage 2 within renderUI for shiny vision project
# stage 2 within our renderUI function
shiny::fluidPage(
shiny::tagList(
# Row 1: our analyzed image
shiny::fluidRow(
column(8, align = "center",
shinycssloaders::withSpinner( # Spinner loading bar
imageOutput("picture2"), # Outputted Image
color = '#999999'
)
@shaun-jacks
shaun-jacks / shiny-vision-server-stage-1-ui.R
Last active March 7, 2019 02:17
UI within renderUI stage 1
## UI STAGE 1 CODE #
# begin a sidebar ui page
shiny::sidebarLayout(
shiny::sidebarPanel(
title = "Image and Analysis Selection",
# ask for file input from user
shiny::fileInput(
inputId = "file1",
label = "Input Image",
accept = c(