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
commaStringFormatter = (speechArray) => { | |
formattedString = [speechArray.slice(0, -1).join(', '), speechArray.slice(-1)[0]].join(speechArray.length < 2 ? '' : ', and '); | |
return formattedString; | |
} |
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
collect($locales)->each(function (string $locale) { | |
collect($fields)->each(function (Field $field) use ($locale) | |
$this->doSomeWork($locale, $field); | |
}); | |
}); |
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
User::query() | |
->where('name', 'LIKE', "%{$searchTerm}%") | |
->orWhere('email', 'LIKE', "%{$searchTerm}%") | |
->get(); |
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
str = str.replace(/[\W_]+/g,''; |
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 moment.js | |
const moment = require('moment'); | |
// Remove date parameter from moment method to get "now" | |
var formattedDate = moment('2018-10-29 13:57:37').format('h:mm A'); | |
alert(formattedDate); |
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
someString = someString.replace(/\s+/g, '-'); |
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
// They are very similar when used like this outside a function block. | |
let me = 'go'; // globally scoped | |
var i = 'able'; // globally scoped | |
// Global variables defined with let will not be added as properties on the global window object like those defined with var | |
console.log(window.me); // undefined | |
console.log(window.i); // 'able' | |
// They are identical when used like this in a function block. | |
function ingWithinEstablishedParameters() { |
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
<style> | |
.resp-iframe { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
border:0; | |
} | |
</style> |
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
-- All live comments | |
SELECT COUNT(*) FROM wp_comments | |
WHERE comment_approved = 1 | |
AND comment_date > '2018-08-22' | |
-- Comment count grouped by author | |
SELECT COUNT(*) AS comment_count, comment_author, user_id FROM wp_comments | |
WHERE comment_approved = 1 | |
AND comment_date > '2018-08-22' | |
GROUP BY user_id |
OlderNewer