Skip to content

Instantly share code, notes, and snippets.

View anxious-coder-lhs's full-sized avatar

Anxious Coder anxious-coder-lhs

View GitHub Profile
@anxious-coder-lhs
anxious-coder-lhs / multiply.js
Created November 16, 2019 19:12
Integer Multiplication as strings
function multiply(first, second) {
if (first === "0" || second === "0") {
return "0";
}
const maxLength = first.length + second.length;
const result = Array(maxLength).fill(0);
for (let i = second.length - 1; i >= 0; i--) {
let opIdx = maxLength - (second.length - i);
for (let j = first.length - 1; j >= 0; j--) {
@anxious-coder-lhs
anxious-coder-lhs / reversal.js
Created November 16, 2019 19:08
String Reversal Javascript
function compute(number) {
let result = new Array(3);
result[1] = result[2] = 1;
for (let i = 3; i <= number; i++) {
let oldResult = result[2];
let lastToOldResult = result[1];
result[2] = result[2] + result[1];
result[1] = oldResult;
result[0] = lastToOldResult;
}
function compute(number) {
let result = new Array(3);
result[1] = result[2] = 1;
for (let i = 3; i <= number; i++) {
let oldResult = result[2];
let lastToOldResult = result[1];
result[2] = result[2] + result[1];
result[1] = oldResult;
result[0] = lastToOldResult;
}
@anxious-coder-lhs
anxious-coder-lhs / multiply.js
Created November 16, 2019 19:04
Karatsuba Integer Multiplication
/**
* Multiply any two numbers as strings using the linear method of operation. Takes O(n)
* Returns the result as an array of numbers in the reverse order.
*
* @param {*} first
* @param {*} second
*/
function mulitiplyLinear(first, second) {
let larger, factor;
if (first.length > second.length) {
@anxious-coder-lhs
anxious-coder-lhs / coding-resources.md
Last active April 10, 2019 07:10
Coding Problems Resources
@anxious-coder-lhs
anxious-coder-lhs / azure-resources.md
Last active March 25, 2019 03:27
List of Azure resources for certification
@anxious-coder-lhs
anxious-coder-lhs / rabbitmq-cluster.md
Created March 20, 2019 11:11 — forked from pobsuwan/rabbitmq-cluster.md
How to config rabbitmq server cluster [3 nodes]

How to config rabbitmq server cluster [3 nodes]

Do after install SLGInstallers

Edit /etc/hosts

vi /etc/hosts
192.168.10.157  rabbitmq-1
192.168.10.159  rabbitmq-2
192.168.10.161  rabbitmq-3
@anxious-coder-lhs
anxious-coder-lhs / kubernetes_add_service_account_kubeconfig.sh
Created February 25, 2019 11:41 — forked from innovia/kubernetes_add_service_account_kubeconfig.sh
Create a service account and generate a kubeconfig file for it - this will also set the default namespace for the user
#!/bin/bash
set -e
set -o pipefail
# Add user to k8s using service account, no RBAC (must create RBAC after this script)
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
echo "usage: $0 <service_account_name> <namespace>"
exit 1
fi
@anxious-coder-lhs
anxious-coder-lhs / ghost-pod-monitor.yaml
Created February 17, 2019 07:20
Ghost pod descriptor with health monitor checks enabled.
apiVersion: v1
kind: Pod
metadata:
name: ghost
labels:
app: ghost
env: prod
spec:
containers:
- name: ghost
@anxious-coder-lhs
anxious-coder-lhs / ghost-pod.yaml
Created February 16, 2019 18:13
Ghost pod K8s file
apiVersion: v1
kind: Pod
metadata:
name: ghost
labels:
app: ghost
env: prod
spec:
containers:
- name: ghost