Skip to content

Instantly share code, notes, and snippets.

@Gerst20051
Gerst20051 / How to Install JDK MacOS Homebrew.md
Created August 10, 2021 03:51 — forked from gwpantazes/How to Install JDK MacOS Homebrew.md
How to install different JDK versions on MacOS with Homebrew

How To Install Different JDK Versions on MacOS with Homebrew

Keywords: Java, JDK (Java Development Kit), MacOS, Homebrew, Specific Version

This how-to guide covers how to install different versions of the JDK on MacOS with Homebrew.

Table of Contents

@Gerst20051
Gerst20051 / slim-redux.js
Created July 1, 2021 00:35 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
# My take on Mike's source_for method.
# (see http://pragmaticstudio.com/blog/2013/2/13/view-source-ruby-methods)
#
# (1) I named it 'src' rather than source_for (ok, I'm a lazy typer).
# (2) The edit function was broken out as a separate function.
# (3) The edit function is for emacs
# (4) If the method is not defined on the object, and the object
# is a class, then see if it is an instance method on the class.
#
# The fourth point allows my to say:
@Gerst20051
Gerst20051 / sqlite.help.txt
Last active June 8, 2021 01:38
SQLite Help
You can terminate the sqlite3 program by typing your systems End-Of-File character (usually a Control-D).
Use the interrupt character (usually a Control-C) to stop a long-running SQL statement.
https://sqlite.org/cli.html
SQLite version 3.28.0 2019-04-15 14:49:49
Enter ".help" for usage hints.
sqlite> .help
.auth ON|OFF Show authorizer callbacks
.backup ?DB? FILE Backup DB (default "main") to FILE
Help
help Show a list of commands or information about a specific command.
Context
cd Move into a new context (object or scope).
find-method Recursively search for a method within a class/module or the current namespace.
ls Show the list of vars and methods in the current scope.
pry-backtrace Show the backtrace for the pry session.
raise-up Raise an exception out of the current pry instance.
reset Reset the repl to a clean state.
@Gerst20051
Gerst20051 / use_npm_lock_versions.js
Last active March 12, 2021 04:56
Use NPM Lock Versions
#!/usr/bin/env node
// COMMAND: ./use_npm_lock_versions.js ~/path/to/your/repo
const fs = require('fs');
const os = require('os');
function init() {
const directory = parseDirectory(process.argv.slice(2)[0]);
const [packageJson, newlineCharacter] = loadPackageJson(directory);
@Gerst20051
Gerst20051 / dimmer.js
Created December 10, 2020 00:33
Dimmer Class
// MIN_LEVEL = 5
// MAX_LEVEL = 15
// Light Switch | Brightnesses for given Bulb Capacity
// Dimmer Level | 5 Watt | 10 Watt | 20 Watt
// 5 | 0 | 0 | 0
// 15 | 5 | 10 | 20
// 10 | 2.5 | 5 | 10
@Gerst20051
Gerst20051 / maximizeCustomerSatisfaction.js
Last active December 9, 2020 22:24
Angry Bookstore Owner - Maximize Customer Satisfaction
// Today, the bookstore owner has a store open for customers.length minutes.
// Every minute, some number of customers (customers[i]) enter the store, and all those customers leave after the end of that minute.
// On some minutes, the bookstore owner is grumpy.
// If the bookstore owner is grumpy on the i-th minute, grumpy[i] = 1, otherwise grumpy[i] = 0.
// When the bookstore owner is grumpy, the customers of that minute are not satisfied, otherwise they are satisfied.
// The bookstore owner knows a secret technique to keep themselves not grumpy for X minutes straight, but can only use it once.
// Return the maximum number of customers that can be satisfied throughout the day.
function maximizeCustomerSatisfaction(customers, grumpy, x) {
const combinations = generateGrumpyCombinations(grumpy, x);
@Gerst20051
Gerst20051 / find_sum.js
Last active December 9, 2020 21:51
Find Sum To Match Target
// find two numbers whose sum equals the target_sum value
function create_digits(numbers) {
const digits = {};
for (let i = 0; i < numbers.length; i++) {
digits[numbers[i]] = 1;
}
return digits;
}
@Gerst20051
Gerst20051 / count_islands.py
Last active June 24, 2021 04:50
Count Islands
#!/usr/bin/env python3
# Given a 2D grid map of 1s (land) and 0s (water), count the number of islands.
# An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically.
# You may assume the grid itself is surrounded by water.
# https://www.geeksforgeeks.org/find-number-of-islands/
# https://www.geeksforgeeks.org/find-the-number-of-distinct-islands-in-a-2d-matrix/
# https://stackoverflow.com/questions/58767533/find-explicitly-islands-in-matrix
# http://www.huristic.co/blog/2016/10/14/finding-islands-in-an-adjacency-matrix