Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
@primaryobjects
primaryobjects / quickSortSpecial.js
Last active September 27, 2020 22:04
Quicksort modified to move all special values (such as zeros) to end of list. https://jsfiddle.net/x74m3yc8/
// Modified quick-sort that allows overriding a value(s) placement to go to the end of the list.
const quickSort = (arr, isSpecialFunc = () => { return false }) => {
let sorted = [];
if (arr && arr.length) {
let left = [];
let right = [];
// Select a random starting location.
const startIndex = 0;
@primaryobjects
primaryobjects / pancake.js
Last active October 19, 2020 19:37
Pancake Sort in Javascript, recursion and recursive solution https://www.geeksforgeeks.org/pancake-sorting Demo https://jsfiddle.net/p6m4sjov
const flip = (list, start) => {
// Reverses the list from 0 to start.
return list.slice(0, start+1).reverse().concat(list.slice(start+1));
};
const pancake = list => {
if (list.length > 1) {
// Pancake sort the list.
let largestIndex = 0;
@primaryobjects
primaryobjects / 1-sum.js
Last active July 7, 2020 22:18
Replace BST nodes with the sum of nodes greater than the node. O(n) https://jsfiddle.net/Lr3mh8op/1/
/* Given a binary tree, replace all node values with the sum of all node values greater than or equal to its own.
Note, in a binary search tree, values to the left are less than the parent, while values to the right are greater than the parent.
*/
const sum = node => {
// Returns the sum of all values in the tree.
return !node ? 0 : node.value + sum(node.left) + sum(node.right);
};
@primaryobjects
primaryobjects / chromedriver.py
Last active October 22, 2022 17:56
Automatically download the latest chromedriver for Selenium in Python. Works on Linux, Mac, Windows. Cross platform!
#!/usr/bin/env python3
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import WebDriverException, SessionNotCreatedException
import sys
import os
import pathlib
import urllib.request
import re
import zipfile
@primaryobjects
primaryobjects / activities.md
Last active May 20, 2020 13:07
Working from home useful links WFH

Activities for Kids

Music Time With Priscilla Cunza-Marin

If you have babies or toddlers, and need to entertain them for 20-30 minutes with a little music, this is a great opportunity! Mondays and Thursdays at 1pm, kids can enjoy a short ukelele sing-along session of their favorite kids songs ("Alphabet song", "Heads, Shoulders, Knees and Toes", "I'm a Little Teapot", etc.) Please sign up and we will forward you the appointment with Zoom link https://us04web.zoom.us/j/907562844

Dance Classes with Karishma Motwani

Go to that important meeting or get that important task done while your kids enjoy 30-40 minutes of dance classes with Karishma Motwani, Mondays and Thursdays at 4:30pm! All ages welcome! Please sign up and we will forward you the appointment with Zoom link. Adults are welcome as well if you'd like to sneak some extra steps in for that step challenge! https://us04web.zoom.us/j/9422118428

Arts and Crafts with Neena Davies

Let your kids get creative learning how to do different arts a

@primaryobjects
primaryobjects / unsplash.sh
Created March 16, 2020 03:05
Automatically change Linux Mint Desktop Wallpaper by downloading a random image from unsplash.com
#!/bin/bash
#
# Add a cron job to run this script every 15 minutes.
# crontab -e
# */15 * * * * /home/YOUR_USER_NAME/Documents/unsplash.sh
#
USER=$(whoami)
# Delete cached wallpaper.
@primaryobjects
primaryobjects / readme.md
Last active July 7, 2025 04:45
How to remote desktop from Linux Mint to Windows 10 with AzureAD Azure AD login

How to remote desktop from Linux Mint to Windows 10 with AzureAD

The following steps detail how to connect over Remote Desktop from Linux Mint or Ubuntu to Windows 10 with an AzureAD username and password login account.

  1. In Windows 10, right-click This PC or My Computer and select Properties.
  2. Click Remote Settings.
  3. Check the option Allow remote connections to this computer.
  4. Uncheck the option Allow connections only from computers running Remote Desktop with Network Level Authentication.
  5. Click OK.
@primaryobjects
primaryobjects / linear-regression.R
Created January 31, 2020 21:50
Linear regression with gradient descent in R.
#
# An example of calculating linear regression with gradient descent for a single variable.
# Kory Becker
# 1/31/2020
#
# Calculate linear regression with gradient descent.
linearRegression <- function(x, y, alpha, iterations) {
# initialize coefficients
theta <- matrix(c(0,0), nrow=2)
@primaryobjects
primaryobjects / udacity-submit.md
Last active January 20, 2020 23:05
How to submit a project to Udacity in Windows with a Google or Facebook login.

How to submit a project to Udacity in Windows

When submitting a project to Udacity with a login on Google or Facebook, you will need to copy a jwt file to your PC in order for the login to work. Here's how.

  1. Save the link https://project-assistant.udacity.com/auth_tokens/new to C:\Users\YOUR_USER_NAME\AppData\Roaming\udacity-pa
  2. Open a CMD in Windows.
  3. Navigate to your project source code folder:

cd c:\projects\aind-sudoku

@primaryobjects
primaryobjects / 1-sudoku-box.py
Last active September 20, 2021 12:49
Sudoku puzzle convert string of values into a dictionary of key/value pairs. Udacity Artificial Intelligence nanodegree project 1, quiz 1: Encoding the Board.
from utils import *
# `grid` is defined in the test code scope as the following:
# (note: changing the value here will _not_ change the test code)
# grid = '..3.2.6..9..3.5..1..18.64....81.29..7.......8..67.82....26.95..8..2.3..9..5.1.3..'
def grid_values(grid):
"""Convert grid string into {<box>: <value>} dict with '.' value for empties.
Args: