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
#!/usr/bin/env php | |
<?php | |
$file = $argv[1]; | |
$contents = file_get_contents($file); | |
/** @var $patterns */ | |
$patterns = [ | |
/** @lang PhpRegExp */ | |
'~<\?=[ ]?([^?]+);?[ ]?\?>~m' => '{{ $1 }}', |
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
.nav { | |
nav-prop: 1; | |
.parent-class { | |
parent-prop: 1; | |
&.sibling-class { | |
grand-child-prop: 1; | |
.grand-child-class { |
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
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)); |
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
<?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";} |
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
/** | |
* S3 migration script | |
* | |
* Use this script to migrate all buckets and files from one S3 server to another. | |
* | |
* Author: Lawrence Cherone | |
*/ | |
const HOSTS = { | |
from: { |
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 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 | |
} |
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 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) | |
} |
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
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 | |
) |
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 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) => { |
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
/* | |
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([ |
NewerOlder