const Moment = require('moment')
const array = [{date:"2018-05-11"},{date:"2018-05-12"},{date:"2018-05-10"}]
const sortedArray = array.sort((a,b) => new Moment(a.date).format('YYYYMMDD') - new Moment(b.date).format('YYYYMMDD'))
console.log(sortedArray)
// functions/income/counter.function.js | |
'use strict' | |
const functions = require('firebase-functions') | |
const admin = require('firebase-admin') | |
// Prevent firebase from initializing twice | |
try { admin.initializeApp(functions.config().firebase) } catch (e) {} |
https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff
While attempting to explain JavaScript's reduce
method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List
is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu
Check out the Remix competition page for details of prizes and updates of the winners!
Random Background using pseudo elements and Sass SVG Animations for Social Icons CSS Animations
A Pen by Elior Shalev Tabeka on CodePen.
/** | |
* MediaFormat | |
* format and return only needed pieces of media from their public sources | |
* Author: Trevor Clarke | |
*/ | |
function MediaFormat (){ | |
// http://www.youtube.com/embed/m5yCOSHeYn4 | |
var ytRegEx = /^(?:https?:\/\/)?(?:i\.|www\.|img\.)?(?:youtu\.be\/|youtube\.com\/|ytimg\.com\/)(?:embed\/|v\/|vi\/|vi_webp\/|watch\?v=|watch\?.+&v=)((\w|-){11})(?:\S+)?$/; | |
// http://vimeo.com/3116167, https://player.vimeo.com/video/50489180, http://vimeo.com/channels/3116167, http://vimeo.com/channels/staffpicks/113544877 | |
var vmRegEx = /https?:\/\/(?:vimeo\.com\/|player\.vimeo\.com\/)(?:video\/|(?:channels\/staffpicks\/|channels\/)|)((\w|-){7,9})/; |
#!/bin/bash | |
# node-reinstall | |
# credit: http://stackoverflow.com/a/11178106/2083544 | |
## program version | |
VERSION="0.0.13" | |
## path prefix | |
PREFIX="${PREFIX:-/usr/local}" |
// Set sizes without units | |
$basefont: 20; | |
$total-width-px: 1169; | |
$column-width-px: 72; | |
// Concatenation of units by addition results in conversion to string. This is bad | |
$basefont-px: $basefont+'px'; // = "20px" | |
// Conversion to pixels using multiplication | |
$basefont-px: $basefont*1px; // = 20px; |
SQL to MongoDB Mapping Chart¶
In addition to the charts that follow, you might want to consider the Frequently Asked Questions section for a selection of common questions about MongoDB.
Executables¶
The following table presents the MySQL/Oracle executables and the corresponding MongoDB executables.
[ | |
{ | |
"hex": "#EFDECD", | |
"name": "Almond", | |
"rgb": "(239, 222, 205)" | |
}, | |
{ | |
"hex": "#CD9575", | |
"name": "Antique Brass", | |
"rgb": "(205, 149, 117)" |