Skip to content

Instantly share code, notes, and snippets.

Knowledge Aquired:
@shawnritchie
shawnritchie / Bowling
Last active September 23, 2015 17:44
Bowling
Rules:
------
- 10 Pins in total
- 10 Frames
- 1 Frame contains 2 rolls
- Open Frame - When not all pins have been knocked down during the 2 rolls in a frame
- Spare - All pins have been knocked down in both rolls for a frame
- Strike - All pins have been knocked down in a single roll for a grame
- Extra Roll - Extra Roll if you hit a spare during your last Frame
- Extra Frame - Extra Frame if you hit a strike during your last Frame

FIZBUZ

Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz” - Optimize the “FizzBuzz” problem

  • Design test cases for the “FizzBuzz” problem

Array Equilibrium

A zero-indexed array A consisting of N integers is given. An equilibrium index of this array is any integer P such that 0 ≤ P < N and the sum of elements of lower indices is equal to the sum of elements of higher indices, i.e. A[0] + A[1] + ... + A[P−1] = A[P+1] + ... + A[N−2] + A[N−1].

Sum of zero elements is assumed to be equal to 0. This can happen if P = 0 or if P = N−1. For example, consider the following array A consisting of N = 7 elements:

A[0] = -7 A[1] = 1 A[2] = 5
@shawnritchie
shawnritchie / how-to-generate-and-use-private-keys-with-openssl-tool.md
Created October 24, 2020 09:46 — forked from briansmith/how-to-generate-and-use-private-keys-with-openssl-tool.md
How to generate & use private keys using the OpenSSL command line tool

How to Generate & Use Private Keys using OpenSSL's Command Line Tool

These commands generate and use private keys in unencrypted binary (not Base64 “PEM”) PKCS#8 format. The PKCS#8 format is used here because it is the most interoperable format when dealing with software that isn't based on OpenSSL.

OpenSSL has a variety of commands that can be used to operate on private key files, some of which are specific to RSA (e.g. openssl rsa and openssl genrsa) or which have other limitations. Here we always use

package com.example.tests;
import com.example.tests.config.TestDatabaseConfig;
import org.flywaydb.core.Flyway;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.context.annotation.PropertySource;
package org.keycloak.authentication.authenticators.browser;
import org.keycloak.authentication.AuthenticationFlowContext;
import org.keycloak.models.RoleModel;
import org.keycloak.models.UserModel;
import javax.ws.rs.core.MultivaluedMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;