const groupBy = key => array =>
array.reduce((objectsByKeyValue, obj) => {
const value = obj[key];
objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
return objectsByKeyValue;
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
import {CustomError} from "./error/custom-error.interface"; | |
require('dotenv').config(); | |
import {RequestHandler} from 'express'; | |
import {MongoClient} from 'mongodb'; | |
let client: MongoClient; | |
const connectToClientIfDropped: () => Promise<void> = async () => { | |
if (client && client.isConnected()) { |
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
--[[ | |
mpv_geometry_freezer.lua | |
Sets the geometry property when window size changes, | |
avoiding Windows' maximized windows detaching. | |
- AMM | |
]]-- | |
local msg = require 'mp.msg' | |
local UPDATE_INTERVAL = 0.5 | |
local screen_w, screen_h = mp.get_osd_size() |
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
import 'package:architecture_playground/home_page.dart'; | |
import 'package:architecture_playground/services.dart'; | |
import 'package:flutter/material.dart'; | |
void main() async { | |
// perform long-running tasks before "runApp" to display the native splash screen | |
final services = await Services.initialize(); | |
runApp(ServicesProvider( | |
services: services, |
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
// Private fields | |
var PAGE_HEIGHT = 700; | |
var PAGE_WIDTH = 500; | |
// Private methods | |
function createNewReport (fileName) { | |
var content = []; |
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
// This file was initially generated by Windows Terminal 0.11.1333.0 | |
// It should still be usable in newer versions, but newer versions might have additional | |
// settings, help text, or changes that you will not see unless you clear this file | |
// and let us generate a new one for you. | |
// To view the default settings, hold "alt" while clicking on the "Settings" button. | |
// For documentation on these settings, see: https://aka.ms/terminal-documentation | |
{ | |
"$schema": "https://aka.ms/terminal-profiles-schema", | |
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", | |
// You can add more global application settings here. |
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
'use strict' | |
/** | |
babel.config.js with useful plugins. | |
*/ | |
module.exports = function(api) { | |
api.cache(true); | |
api.assertVersion("^7.4.5"); | |
const presets = [ | |
[ |
Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt
If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a
I will be using the root user, but would suggest creating a new user
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
async function fetchAndUpdatePosts() { | |
const posts = await fetchPosts().catch(() => { | |
console.log('error in fetching posts'); | |
}); | |
if (posts) { | |
doSomethingWithPosts(posts); | |
} | |
} |
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
using namespace System.Management.Automation | |
using namespace System.Management.Automation.Language | |
if ($host.Name -eq 'ConsoleHost') | |
{ | |
Import-Module PSReadLine | |
} | |
#Import-Module PSColors | |
#Import-Module posh-git | |
Import-Module -Name Terminal-Icons |