Skip to content

Instantly share code, notes, and snippets.

interface IFruit {
name: string
qty: number
price: number
}
const FruitStand = () => {
const fruits = new Map<string, IFruit>();
const addFruit = (name: string, qty: number, price: number) => {
@AngeloAnolin
AngeloAnolin / uniqueSum.ts
Last active April 2, 2024 16:04
Add array values if digits does not contain any repeating number
const uniqueSum = (arr: number[]) => {
// Filter any number from the array that has repeating digits
const filterRepeatingDigits = (num: number) => {
const digits = num.toString().split('');
return digits.length === new Set(digits).size;
}
// Obtain an array of numbers containing only numbers w/ non-repeating digits
const filtered = arr.filter(filterRepeatingDigits)
@AngeloAnolin
AngeloAnolin / gist:1b97a60d6fa3472965a2b13029445d13
Created February 26, 2024 20:53
Given a number and a digit to remove from that number, maximize the resulting number after the digit has been removed and print it.
/*
From the challenge provided, it is evident that the right-most number should be removed to get the maximum value when the digit is removed.
*/
const removeDigit = (val, digit) => {
const length = digit.toString().length
if (length > 1) {
return console.log(`You can only pass a single digit`)
}
const str = val.toString()
@AngeloAnolin
AngeloAnolin / gist:5712d6bae230badfe243558a08a16d77
Created January 19, 2024 14:06
Flip 2D array vertically or horizontally.
let array = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
const flip = (array, direction = 'HORIZONTAL') => {
const temp = [...array]
if (direction.toUpperCase() === 'VERTICAL') {
return (temp.reverse())
@AngeloAnolin
AngeloAnolin / ns-error-001.txt
Created October 27, 2018 16:33
NativeScript Error
Skipping node_modules folder! Use the syncAllFiles option to sync files from this folder.
Searching for devices...
Your application will be deployed only on the device specified by the provided index or identifier.
Executing before-watchPatterns hook from /Users/angelo/Projects/Round2Ipad/hooks/before-watchPatterns/nativescript-dev-webpack.js
Executing before-watch hook from /Users/angelo/Projects/Round2Ipad/hooks/before-watch/nativescript-dev-webpack.js
Copying template files...
Platform ios successfully added. v4.2.0
Executing before-shouldPrepare hook from /Users/angelo/Projects/Round2Ipad/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Preparing project...
Executing before-prepareJSApp hook from /Users/angelo/Projects/Round2Ipad/hooks/before-prepareJSApp/nativescript-dev-webpack.js
@AngeloAnolin
AngeloAnolin / web.config
Created March 11, 2017 02:56
Web Configuration for Vue Applications Hosted in IIS
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />