Skip to content

Instantly share code, notes, and snippets.

@thorizer
thorizer / README.md
Created April 1, 2022 03:49 — forked from kasperpeulen/README.md
How to pretty-print JSON using Dart.
@thorizer
thorizer / 0_main.dart
Created March 16, 2022 20:39 — forked from boformer/0_main.dart
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,
@thorizer
thorizer / postgres-cheatsheet.md
Created December 31, 2021 15:04 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@thorizer
thorizer / node_nginx_ssl.md
Created December 9, 2020 03:59 — forked from bradtraversy/node_nginx_ssl.md
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

@thorizer
thorizer / async.eashSeries.js
Created May 13, 2020 22:16 — forked from guyellis/async.eashSeries.js
async.eachSeries()
var async = require('async');
var arr = [1,2,3,4];
async.eachSeries(arr,function(item, cb){
setTimeout(function() {
console.log('#1: ', item);
return cb();
}, Math.random()*2000);
}, function(err){
@thorizer
thorizer / node-folder-structure-options.md
Created May 4, 2020 10:48 — forked from lancejpollard/node-folder-structure-options.md
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin
@thorizer
thorizer / Expected behavior.js
Last active April 28, 2020 02:02
Group objects by multiple properties including nested properties and sump up their values
//Input :************************************************************************************************************************************
[
{
"commissioningDate": "2019-09-27",
"_product": {
"_id": "aaa",
"name": "Installation"
},
"zones": [
@thorizer
thorizer / README.md
Created April 27, 2020 21:32 — forked from joyrexus/README.md
Nested grouping of arrays

nest.js

A multi-level groupBy for arrays inspired by D3's nest operator.

Nesting allows elements in an array to be grouped into a hierarchical tree structure; think of it like the GROUP BY operator in SQL, except you can have multiple levels of grouping, and the resulting output is a tree rather than a flat table. The levels in the tree are specified by key functions.

See this fiddle for live demo.

@thorizer
thorizer / groupBy
Created April 27, 2020 14:24 — forked from awsp/groupBy
Javascript - multiple groupBy function
/**
* Javascript -
* Array multiple groupBy function
* Forked from http://codereview.stackexchange.com/questions/37028/grouping-elements-in-array-by-multiple-properties
*
* Usage:
* var list = [
* { foo: "bar", id: 1 },
* { foo: "barbar", id: 2 },
* { foo: "bar", id: 1 },