This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
// First of all you will create a package.json file | |
// So need to run NPM i or YARN ADD to install Express dependencies | |
// After that, you will put the generated build folder in the same folder as this server | |
// So you just run the serve :) | |
const app = express() | |
const baseDir = `${__dirname}/build/` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TAX_RATE = 1.1; | |
const DEFAULT_SHIPPING = 5; | |
function calculateTotal(items, {shipping = DEFAULT_SHIPPING, discount = 0} = {}) { | |
if (!Array.isArray(items) || !items.length) return 0; | |
const itemsCost = items.reduce((total, item) => (total += item.quantity * item.price), 0); | |
const discountRate = (discount / 100) || 1; | |
return itemsCost * discountRate * TAX_RATE + shipping; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace CustomURLProtocol | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string appName = "CustomURLProtocol"; | |
string appPath = @"C:\AppToOpen.exe"; | |
RegistryKey key = Registry.ClassesRoot.OpenSubKey(appName); //open appName protocol's subkey |

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This validator does not check the formatting of the documents. | |
// Documents can be passed with or without formatting characters. | |
const processes = { | |
cpf: { | |
length: 11, | |
validator: [11, 10, 9, 8, 7, 6, 5, 4, 3, 2], | |
validationRegex: (d1, d2) => `([0-9]{9}${d1}${d2})`, | |
format: [/(\d{3})(\d{3})(\d{3})(\d{2})/, "$1.$2.$3-$4"], | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _ from 'lodash'; | |
// interface OptionsTypes { | |
// defaultReturn?: string; | |
// truthyOnly?: boolean; | |
// } | |
// interface HandleValueParams { | |
// obj: object; | |
// properties: string[]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
; Define a custom message | |
[HKEY_CLASSES_ROOT\Directory\Background\shell\Windows Terminal] | |
@="Open with Windows Terminal" | |
; Define a custom icon, remove the following two lines to omit the icon | |
[HKEY_CLASSES_ROOT\Directory\Background\shell\Windows Terminal] | |
"Icon"="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react' | |
export function useLocalStorage<T>( | |
key: string, | |
initialValue: T | |
): [T, (params: T | ((prevValue: T) => T)) => void, () => void] { | |
const [storedValue, setStoredValue] = useState(() => { | |
try { | |
const item = window.localStorage.getItem(key) |