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
'use strict'; | |
const moment = require('moment'); | |
/** | |
* Returns a {key: value} object where the key is a start date and the value is the date + 1 of the type of interval | |
* to the start date. When for weeks or months, it shows just the first date of the week/month. | |
* | |
** For days (start: '2017-12-25', end: '2018-01-02', interval: 'day'): | |
{ '2017-12-25': '2017-12-26', |
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
//How To Compare Object Values | |
var a = { blah: 1 }; | |
var b = { blah: 1 }; | |
var c = a; | |
var d = { blah: 2 }; | |
Object.compare = function (obj1, obj2) { | |
//Loop through properties in object 1 | |
for (var p in obj1) { | |
//Check property exists on both objects |
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
// IMPORTANT: | |
// As of nedb@^1.7.0, Datastore now inherits from EventEmitter in the NeDB core module. | |
// If you need to support older versions of NeDB, please look at the following previous revision | |
// of this gist: | |
// https://gist.github.com/JamesMGreene/0e0b2506c7bd2a2557f7/d8b4b1e97bb0d118c509672e3c7276b6dc4ba13a | |
/* | |
This gist provides a module which derives from the NeDB Datastore module and extends it to | |
emit several important events: |
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
sudo add-apt-repository ppa:ondrej/php | |
sudo apt-get update | |
sudo apt-get install php7.1 | |
sudo apt-get install php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-fpm php7.1-intl php7.1-simplexml | |
sudo a2dismod php7.2 | |
sudo a2enmod php7.1 | |
sudo service apache2 restart | |
sudo update-alternatives --set php /usr/bin/php7.1 | |
sudo update-alternatives --set phar /usr/bin/phar7.1 | |
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.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
// props to Mathias Bynens @mathias (twitter) | |
const promises = [ | |
fetch('/api-call-1'), | |
fetch('/api-call-2'), | |
fetch('/api-call-3') | |
]; | |
// imagine some of these requests fail and some succeed. |
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
Array.prototype.partition = function(predicate) { | |
const results = [[], []]; | |
this.forEach((item, index) => { | |
results[predicate(item, index) ? 0 : 1].push(item); | |
}); |
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 promises = [ | |
fetch('/api-call-1'), | |
fetch('/api-call-2') | |
]; | |
// Imagine some of these requests fail, and some succeed. | |
const results = await Promise.allSetted(promises); | |
// [ |
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 | |
$disk = Storage::disk('s3'); | |
$disk->put($filename, fopen($this->filePath, 'r+')); | |
return Storage::disk('s3')->temporaryUrl($filename, now()->addWeek()); |
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 | |
function tinker(...$args) { | |
// Because there is no way of knowing what variable names | |
// the caller of this function used with the php run-time, | |
// we have to get clever. My solution is to peek at the | |
// stack trace, open up the file that called "tinker()" | |
// and parse out any variable names, so I can load | |
// them in the tinker shell and preserve their names. |
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 | |
's3-backups' => [ | |
'driver' => 's3', | |
'key' => config('aws.public_key'), | |
'secret' => config('aws.secret_key'), | |
'region' => config('aws.region'), | |
'bucket' => $bucket_name | |
] |