Skip to content

Instantly share code, notes, and snippets.

@manzaloros
manzaloros / gist:0458e2ca50de392c1f841d775b3e95c5
Last active August 8, 2020 16:25
Working API call to product no. 1
URL: 127.0.0.1:3000/1
[
{
"id": 1,
"url": "https://mykea-main-title-pictures.s3.us-east-2.amazonaws.com/27.jpg",
"description_id": 1,
"description": "Fuga est quibusdam molestias adipisci tenetur pariatur quis voluptas vitae maxime adipisci et voluptatem odit autem placeat id iste velit quam quibusdam cumque ipsam rerum iste fugit est molestias aut."
},
{
@manzaloros
manzaloros / .block
Created August 14, 2020 13:42 — forked from mbostock/.block
General Update Pattern, I
license: gpl-3.0
redirect: https://observablehq.com/@d3/selection-join
@manzaloros
manzaloros / core-db-query-sample-results
Created September 2, 2020 19:46
core-db-query-sample-results
reviews=# select * from "Reviews" join "Guitars" on "Reviews"."guitarId"= "Guitars"."id" where "Guitars".id = 21;
id | guitarId | rating | author | date | description | id | name | productId
----------+----------+--------+---------------------+-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----+
@manzaloros
manzaloros / artillery-config.yaml
Created September 4, 2020 22:56
Service and Proxy Dev RPS setup/config details + results
# Change port for service/proxy
target: "http://localhost:3000"
phases:
- duration: 60
arrivalRate: 5
name: Warm up
- duration: 120
arrivalRate: 5
rampTo: 1000
name: Ramp up load
@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.
@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 / 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;
}, []);
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;
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 {
@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;