Directly from CLI
alias x='exit'
funcsave x
or create a file in
~/.config/fish/functions
with name
Directly from CLI
alias x='exit'
funcsave x
or create a file in
~/.config/fish/functions
with name
function longest_symm_substr(s) { | |
let longest_symmetric = ''; | |
for(let i=0;i<s.length-1;i++){ | |
// this loop will each time get a new substring incrementing the index from 0 to length | |
let curr_str = s.substring(i); | |
for(let j=curr_str.length-1;j>0;j--){ | |
// this loop will find all possible symmetric substrings in the above indexed substring | |
let str = curr_str.substring(0,j) | |
if(str === str.split('').reverse().join('')){ | |
if(longest_symmetric.length < str.length){ |
function maskify(creditCard) { | |
if (creditCard.length < 6) return creditCard; | |
const last4Characters = creditCard.substr(-4); | |
const firstCharacter = creditCard.substr(0, 1); | |
const maskingCharacters = creditCard.substr(1, creditCard.length - 5).replace(/\d/g, '#'); | |
return `${firstCharacter}${maskingCharacters}${last4Characters}`; | |
} | |
// let assert = require('chai').assert | |
// require('mocha').describe; |
function rgbToHex([red = 0, green = 0, blue = 0] = []) { | |
// Left shift (<<) operator for color conversion is interesting | |
// the color value for each component of an RGB color is between 0 - 255 (8bits) | |
// The first 8 bits starting from the right will represent the blue component, | |
// the next 8 bits will represent the green component, and the 8 bits after that will represent the red component | |
return `#${(red << 16 | green << 8 | blue).toString(16)}`; | |
} | |
function hexToRgb(hex) { | |
// working through above shift operator procedure backwards | |
// we will right-shift the color bits by multiples of 8 as necessary until |
const setTimeouts = []; | |
export function customSetTimeout(cb, interval) { | |
const now = window.performance.now(); | |
const index = setTimeouts.length; | |
setTimeouts[index] = () => { | |
cb(); | |
}; | |
setTimeouts[index].active = true; | |
const handleMessage = (evt) => { | |
if (evt.data === index) { |