Skip to content

Instantly share code, notes, and snippets.

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
@dbayarchyk
dbayarchyk / promiseCatchWithAwait.js
Created October 1, 2019 13:14
Async/await without try/catch in JavaScript
async function fetchAndUpdatePosts() {
const posts = await fetchPosts().catch(() => {
console.log('error in fetching posts');
});
if (posts) {
doSomethingWithPosts(posts);
}
}
@bradtraversy
bradtraversy / node_nginx_ssl.md
Last active May 6, 2024 13:21
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@gtzilla
gtzilla / babel.config.js
Created September 14, 2019 12:42
An example of the new babel.config.js.
'use strict'
/**
babel.config.js with useful plugins.
*/
module.exports = function(api) {
api.cache(true);
api.assertVersion("^7.4.5");
const presets = [
[
@fcharlie
fcharlie / profile.json
Last active December 18, 2022 20:38
My Windows Terminal profile.json
// 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.
@keego
keego / screenshot.js
Last active June 9, 2021 19:40 — forked from poissoj/splitImage.js
Uses `html2canvas` to take screenshots each element in an html NodeList, then uses `pdfMake` to concatenate them into a pdf and download it. (ES5 for AngularJS)
// Private fields
var PAGE_HEIGHT = 700;
var PAGE_WIDTH = 500;
// Private methods
function createNewReport (fileName) {
var content = [];
@boformer
boformer / 0_main.dart
Last active September 3, 2023 19:40
Flutter Service Architecture
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,
@TheAMM
TheAMM / mpv_geometry_freezer.lua
Created November 13, 2018 23:33
mpv_geometry_freezer.lua keeps your mpv window size unchanging
--[[
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()
@JamieMason
JamieMason / group-objects-by-property.md
Created September 14, 2018 07:38
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
@jsdevtom
jsdevtom / index.ts
Created July 29, 2018 14:43
Connect to MongoDB from Google Cloud function best practice through Maintaining Persistent Connections
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()) {