View input.scss
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
.nav { | |
nav-prop: 1; | |
.parent-class { | |
parent-prop: 1; | |
&.sibling-class { | |
grand-child-prop: 1; | |
.grand-child-class { |
View php.js
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
function abs(mixed_number) { | |
return Math.abs(mixed_number) || 0; | |
} | |
function acos(arg) { | |
return Math.acos(arg); | |
} | |
function acosh(arg) { | |
return Math.log(arg + Math.sqrt(arg * arg - 1)); |
View file.php
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
<?php | |
$str = 'a:1:{s:3:"foo";s:23:"https://beta.domain.com";}'; | |
echo serialize(json_decode(str_replace('beta.domain.com', 'domain.com', json_encode(unserialize($str))), true)); | |
// a:1:{s:3:"foo";s:18:"https://domain.com";} |
View script.js
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
/** | |
* S3 migration script | |
* | |
* Use this script to migrate all buckets and files from one S3 server to another. | |
* | |
* Author: Lawrence Cherone | |
*/ | |
const HOSTS = { | |
from: { |
View index.js
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 range = (start, end, step) => { | |
const range = [] | |
typeof step === 'undefined' && (step = 1) | |
if (end < start) step = -step | |
while (step > 0 ? end >= start : end <= start) { | |
range.push(start) | |
start += step | |
} | |
return range | |
} |
View script.js
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 queue = [] | |
Object.defineProperty(queue, 'push', { | |
configurable: true, | |
enumerable: false, | |
writable: true, | |
value: function (...args) { | |
console.log('queue changed') | |
if (typeof args[0] === 'function') args[0]() | |
return Array.prototype.push.apply(this, args) | |
} |
View script.js
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
console.log('asynchronous IIAFE in a for loop, with step timing') | |
for (let i = 0; i <= 10; i++) | |
setTimeout( | |
async () => | |
(async function (index) { | |
console.log(index) | |
})(i), | |
i * 250 | |
) |
View script.js
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 array1 = [ | |
{ name: 'a', creationDate: new Date() }, | |
{ name: 'b', creationDate: new Date() }, | |
] | |
const array2 = [ | |
{ name: 'a', creationDate: new Date() }, | |
{ name: 'c', creationDate: new Date() }, | |
] | |
const mergeBy = (...arrays) => { |
View script.js
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
/* | |
You saw it here first, out of the 8k dupes on stackoverflow, none address diff length b array, diff keys or reference. | |
Leave a comment if you know a better way | |
*/ | |
const a = [{ a: 'a' }, { b: 'b' }]; | |
const b = [{ a: 'a' }, { c: 'c' }, { x: 'x' }, {}]; | |
const merge = (a, b) => [ | |
...new Set([ |
View fnv.js
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
/** | |
* FNV hash | |
* - 32 bit FNV-1a hash | |
* - 64 bit FNV-1a hash | |
* @link http://isthe.com/chongo/tech/comp/fnv/ | |
* | |
* Usage: | |
* fnv.hash('Hello World', 32) // 3012568359 | |
* fnv.hash('Hello World', 64) // 3599595964 | |
*/ |
NewerOlder