Skip to content

Instantly share code, notes, and snippets.

Gerst20051 / How to Install JDK MacOS
Created Aug 10, 2021 — forked from gwpantazes/How to Install JDK MacOS
How to install different JDK versions on MacOS with Homebrew
View How to Install JDK MacOS

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 / slim-redux.js
Created Jul 1, 2021 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
View slim-redux.js
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])) {
View source_for.rb
# My take on Mike's source_for method.
# (see
# (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:
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.
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 Show a list of commands or information about a specific command.
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 / use_npm_lock_versions.js
Last active Mar 12, 2021
Use NPM Lock Versions
View use_npm_lock_versions.js
#!/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);
View dimmer.js
// 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 / maximizeCustomerSatisfaction.js
Last active Dec 9, 2020
Angry Bookstore Owner - Maximize Customer Satisfaction
View maximizeCustomerSatisfaction.js
// 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 / find_sum.js
Last active Dec 9, 2020
Find Sum To Match Target
View find_sum.js
// 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;
#!/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.