Skip to content

Instantly share code, notes, and snippets.

View isabolic's full-sized avatar

isabolic99 isabolic

View GitHub Profile
@isabolic
isabolic / proxy.js
Last active April 1, 2022 06:37
nodejs proxy example
const express = require('express');
const morgan = require("morgan");
const cors = require('cors');
const { createProxyMiddleware } = require('http-proxy-middleware');
// Create Express Server
const app = express();
// cors
app.use(cors())
@isabolic
isabolic / http-error.js
Created September 13, 2019 08:10 — forked from TooTallNate/http-error.js
HTTPError class for JavaScript HTTP errors
import { format } from 'url';
import { STATUS_CODES } from 'http';
import uppercamelcase from 'uppercamelcase';
class HTTPError extends Error {
constructor(code, message, extras) {
super(message || STATUS_CODES[code]);
if (arguments.length >= 3 && extras) {
Object.assign(this, extras);
}
ssh-add -K ~/.ssh/NEW_rsa
import { group, sleep } from 'k6';
import http from 'k6/http';
// Version: 1.3
// Creator: Load Impact URL test analyzer
export let options = {
stages: [
{
"duration": "24s",
@isabolic
isabolic / G964_findNb.ts
Created January 4, 2018 07:56
Build a pile of Cubes
export class G964 {
public static findNb(m: number): number {
// create an endless loop that increments n, the cube number, starting with a value of 1
for ( var n = 0;;n++ ) {
if ( m > 0 ) {
// if m, the total volume, is not 0, we will subtract the volume of the current cube from it
// first calculate the volume of the current cube
let currCubeVol = Math.pow( n+1, 3);
// subtract the current cube volume from the total volume
@isabolic
isabolic / disemvowel.ts
Created January 4, 2018 07:41
disemvowel.ts
export class Kata {
static disemvowel(str: string) {
return str.replace(new RegExp('[AEIOUaeiou]', 'g'), '');
}
}
@isabolic
isabolic / G964.ts
Last active January 3, 2018 08:04
G964.ts
/*
Given two arrays of strings a1 and a2 return a sorted array r in lexicographical order of the strings of a1 which are substrings of strings of a2.
#Example 1: a1 = ["arp", "live", "strong"]
a2 = ["lively", "alive", "harp", "sharp", "armstrong"]
returns ["arp", "live", "strong"]
#Example 2: a1 = ["tarp", "mice", "bull"]
@isabolic
isabolic / SmallestIntegerFinder.js
Created January 2, 2018 14:38
SmallestIntegerFinder.js
class SmallestIntegerFinder {
findSmallestInt(args) {
return args.sort(function(a, b) {
return a - b;
})[0];
}
}
//test
Test.describe("Smallest Integer Tests", _ => {
@isabolic
isabolic / Multiplesof3or5.js
Created January 2, 2018 14:34
Multiplesof3or5
function solution(maxN){
let numbers=[3,5];
let passingNs = [];
let ret = 0;
for (let i = 1; i < maxN; i++) {
numbers.forEach(n => {
if (i * n < maxN && passingNs.indexOf((i*n)) === -1) {
passingNs.push(i*n);
}
});
@isabolic
isabolic / isTriangle.js
Last active January 2, 2018 13:56
isTriangle
// Heron's Formula
function isTriangle(a,b,c)
{
return (a < (b + c)) && ((a + b) > c) && ((a+c) > b);
}
isTriangle(1,2,2) // => true
isTriangle(7,2,2) // => false
isTriangle(1,2,5) // => false
isTriangle(4,2,3) // => true