This file contains 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
http://github.com |
This file contains 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
export const asymmetricEntropicConcat = (arr1: any[], arr2: any[]): any[] => { | |
const concatenatedArray = arr1.concat(arr2); | |
for (let i = concatenatedArray.length - 1; i > 0; i--) { | |
const j = Math.floor(Math.random() * (i + 1)); | |
// Swap elements using a temporary variable | |
const temp = concatenatedArray[i]; | |
concatenatedArray[i] = concatenatedArray[j]; | |
concatenatedArray[j] = temp; |
This file contains 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 getRandomPercentageElements = (array, percentage) => { | |
if (!Array.isArray(array) || array.length === 0 || typeof percentage !== 'number' || percentage < 0 || percentage > 100) { | |
throw new Error('Invalid input'); | |
} | |
const numberOfElements = Math.ceil(array.length * (percentage / 100)); | |
return getRandomEntriesFromArray(array, numberOfElements); | |
} | |
const getRandomEntriesFromArray = (array, numberOfElements) => { | |
if (!Array.isArray(array) || array.length === 0 || typeof numberOfElements !== 'number' || numberOfElements < 0 || numberOfElements > array.length) { |
This file contains 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
// Requires window | |
const parseColor = (input) => { | |
var div = document.createElement('div'); | |
document.body.appendChild(div) | |
div.style.color = input; | |
const style = window.getComputedStyle(div); | |
const ret = style.color.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i); | |
document.body.removeChild(div); | |
if(ret) { |
This file contains 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
export const addFixed = (a: number, b: number, p = 0) => { | |
const t = Number(`1${'0'.repeat(p)}`); | |
return (a * t + b * t) / t; | |
}; |
This file contains 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
export const addFixed = (a: number, b: number, p = 0) => { | |
const countDecimal = (a: number): number => String(a).split('.')[1].length; | |
const dec = isNaN(p) ? Math.max(countDecimal(a), countDecimal(b)) : p; | |
const t = Number(`1${'0'.repeat(dec)}`); | |
return (a * t + b * t) / t; | |
}; |
This file contains 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 makePamphlet = (suspectInput) => { | |
const input = Boolean(suspectInput % 2) ? suspectInput + 1 : suspectInput; | |
const evenPages = [ | |
...Array(input / 2) | |
.fill(0) | |
.map((_el, idx) => (idx + 1) * 2), | |
].reverse(); | |
const oddPages = [ | |
...Array(input) | |
.fill(0) |
This file contains 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
export default (tr) => { | |
const hasLength = (val) => val.length | |
const noTest = () => true | |
const notZero = (val) => val !== 0 | |
const types = { | |
'symbol': (val) => val.description === "", | |
'function': noTest, | |
'undefined': noTest, | |
'bigint': notZero, | |
'object': (val) => Object.is(val, {}), |
This file contains 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
{ | |
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json", | |
"basics": { | |
"name": "Lavi Yatziv", | |
"label": "Senior Web Developer", | |
"image": "", | |
"email": "lavi.yatziv@gmail.com", | |
"phone": "", | |
"url": "http://www.fixedspace.com", | |
"summary": "A graduate of Carleton University's Film program as well as Algonquin College's Radio and TV Broadcasting studies, my work is situated at the juncture between digital and more traditional media. My thorough understanding of both allows me to create beautiful yet functional websites, promotional videos and animation. Troubleshooting and improving functionality for existing websites are among my specialties.", |
This file contains 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
/** | |
* Converts object properties to query string. | |
* @param {object} props - The object used to construct the query string. | |
* @return {string} The query string. | |
*/ | |
export default (props) => { | |
return typeof props === 'object' | |
? `?${Object.keys(props).map((prop) => `${prop}=${props[prop]}`).join('&')}` | |
: '' | |
} |
NewerOlder