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 plateNumberRexEx = /^(KWL|ABC|BWR|RSH|JJJ|AAA|LSR|FKJ|FST|APP|AGL|EPE|LND|MUS|KRE|FNN|SGB|LES|EDE|GBN|BAT|CRC|BDW|DDM|BKR|DMS|NGW|JBY|KFY|BRE|DJA|MLF|KTN|DTS|BDJ|GBR|SEY|LUY|AME|MAP|NRK|BJE|KAM|ANA|CAL|KMM|BRA|DUK|GEP|BNS|EFE|GGJ|CKK|TGD|UDU|BKS|GWL|NSR|UGG|KMC|TRN|DTF|DAL|KER|EFY|ADK|EMR|AMK|KLE|TUN|WEN|KEK|AKR|KTP|FFN|REE|SUA|JTA|NND|ABU|AHD|KNM|ABM|NDN|BGM|BNY|DEG|NCH|MHA|KHE|KPR|SKP|BRR|RUM|RGM|GGU|KRK|BER|PBT)-\d{3}[A-Z]{2}$/gi; | |
| function validatePlateNumber(pn: string): boolean{ | |
| return plateNumberRexEx.test(pn) | |
| } |
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 { Type } from '@nestjs/common'; | |
| import { | |
| ApiProperty, | |
| ApiPropertyOptions, | |
| ApiResponse, | |
| ApiResponseOptions, | |
| } from '@nestjs/swagger'; | |
| export const CustomApiResponseArray = <T>( | |
| entity: Type<T>, |
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
| fn prompt(msg:&str) -> String { | |
| println!("{msg}"); | |
| let mut input:String = String::new(); | |
| std::io::stdin().read_line(&mut input).expect("Could not read input"); | |
| return input; | |
| } | |
| let guess_value:String = prompt("How many times do you want to try"); |
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
| /** | |
| * @author Micah Effiong <micaiah.effion@gmail.com> | |
| * @name getAlphaNumeric | |
| * @description get all alphabets and numbers | |
| * @returns {String} | |
| */ | |
| function getAlphaNumeric() { | |
| return String.fromCharCode(...Array(123).keys()) | |
| .slice(48) | |
| .match(/[a-zA-Z0-9]/gi) |
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
| /** | |
| * @name currencyAmount | |
| * @description format digit as currency value | |
| * @param {Number|String} amount | |
| * @param {String} currency | |
| * @param {String} [symbol] currency symbol. Use for currencies that are not recogonized by Javacript | |
| * @example | |
| * currencyAmount(1000, "USD") // => $1,000.00 | |
| * currencyAmount(1000, "NGN") // => NGN 1,000.00 | |
| * currencyAmount(1000, "NGN", "₦") // => ₦1,000.00 |
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
| /** | |
| * @description convert kilometer to radius | |
| * @param {Number} km digit in kilometer | |
| * @returns {Number} earth's equatorial radius | |
| */ | |
| function kmToRad(km) { | |
| return km / 6371; | |
| } |
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 { Op } = require("sequelize"); | |
| function queryToSequelize(query) { | |
| let queryStr = JSON.stringify(query); | |
| let q2 = {}; | |
| Object.keys(query).filter((val) => { | |
| if (query[val] instanceof Object && !(query[val] instanceof Array)) { | |
| q2[val] = queryToSequelize(query[val]); | |
| return; | |
| } |
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
| /** | |
| * @author Micah Effiong <micaiah.effiong@gmail.com> | |
| * | |
| * @param {Number} r - red | |
| * @param {Number} g - green | |
| * @param {Number} b - blue | |
| * @returns {String} - hex value | |
| */ | |
| function rgb(r, g, b) { | |
| return [r, g, b].map(num => { |
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
| /* | |
| * @author Micah Effiong | |
| * @desc convet an HTML form to JSON for sending in request body | |
| * @param {HTMLFormElement} formElement - The from to be converted | |
| * @returns {Object} - The object containing the form inputes (name and value) | |
| */ | |
| function formToJSON(formElement) { | |
| const obj = Object.create(null); |
NewerOlder