Skip to content

Instantly share code, notes, and snippets.

@manzaloros
manzaloros / sdi-how-to-ask-for-help.md
Created February 1, 2021 15:03
sdi how to ask for help

How to ask for help

Completely refactor the question

  • The question must make sense to you before you ask it

Google and stack overflow, a lot!

  • Avoid being seen as a 'help vampire'

Go through entire debugger's question

  • This seems to be a hack reactor idea
@manzaloros
manzaloros / .vimrc
Last active January 31, 2021 03:32
My .vimrc
" leader as spacebar
let mapleader = " "
" Enable syntax highlighting
syntax on
" Search Highlighting
set hlsearch
" Mute highlighting
nnoremap <silent> <C-l> :<C-u>nohlsearch<CR><C-l>
/*
Kth Missing Positive Number
Given an array arr of positive integers sorted in a strictly increasing order, and an integer k.
Find the kth positive integer that is missing from this array.
Example 1:
@manzaloros
manzaloros / .bash_profile
Last active February 5, 2021 02:24
My .bash_profile
# Aliases go in bashrc, customizing $PATH environment variable in bash_profile
export PS1="___________________ | \w @ \h (\u) \n| => "
export PS2="| => "
# Aliases
alias git-pull-all="find . -maxdepth 3 -name .git -type d | rev | cut -c 6- | rev | xargs -I {} git -C {} pull"
# Update bashrc gist: https://gist.github.com/Ashwinning/35f530be96754e71a138af842d147cf8
alias gistbash="gist -u 9d5f4e7e2139d93e6011f529d06c8b38 ~/.bash_profile"
@manzaloros
manzaloros / Calculations.java
Last active December 8, 2020 22:48
Spring Calculator
package com.galvanize.demo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
import static java.lang.Integer.parseInt;
const getDecimalValue = (head, [currentNode, string] = [head, '']) => {
do {
string += currentNode.val;
currentNode = currentNode.next;
} while (currentNode)
return parseInt(string, 2);
}
const getDecimalValue = (h, [c, a] = [h, []]) => {
do {
const maxDistToClosest = (seats,
[maxDist, i, j] = [0, 0, 1],
{ length } = seats) => {
const leftSeatOccupied = () => seats[i] === 1;
const rightSeatOccupied = () => seats[j] === 1;
const isEndOfRow = () => (j + 1) === length;
const distanceToEndOfRow = () => j - i;
const distanceBetweenSeats = () => Math.ceil(((j - 1) - i) / 2);
const seatsLeftInRow = () => j < length;
const checkNextRightSeat = () => j += 1;
@manzaloros
manzaloros / summaryRanges.js
Last active October 28, 2020 15:48
summaryRanges.js
const summaryRanges = (nums, [beginning, end] = [nums[0]]) => {
return nums.reduce((result, curr, i) => {
const next = nums[i + 1];
if (curr + 1 !== (next)) {
result.push(end === beginning ? `${end}` : `${beginning}->${end}`);
beginning = next;
}
end = next;
return result;
}, []);
@manzaloros
manzaloros / removeCoveredIntervals.js
Last active October 4, 2020 16:50
removeCoveredIntervals
const removeCoveredIntervals = (intervals) => {
let coveredIntervalsCount = 0;
const compareSet = new Set();
for (let i = 0; i < intervals.length; i += 1) {
const current = intervals[i];
for (let j = 0; j < intervals.length; j += 1) {
if (j === i || compareSet.has((intervals[j].toString()))) {
continue;
}
const compare = intervals[j];
@manzaloros
manzaloros / proxy-stress-test-results.txt
Created September 11, 2020 23:59
Proxy Stress Test Results
Loader.io test:
Endpoint: http://<proxy>/reviews/api/item/%{*:1-10000000}/reviews
Specifications: 400 clients per second over 1 minute
New Relic results:
Peak throughput: 292 rps
Peak latency: 650ms.