Skip to content

Instantly share code, notes, and snippets.

View RyanDsilva's full-sized avatar
:octocat:
Always Learning

Ryan Dsilva RyanDsilva

:octocat:
Always Learning
View GitHub Profile
@RyanDsilva
RyanDsilva / pm2-ecosystem.config.js
Last active July 5, 2020 15:35
Basic PM2 configuration for a single application deployment
module.exports = {
apps: [
{
name: "server",
script: "server.js",
instances: "max",
exec_mode: "cluster",
env_production: {
NODE_ENV: "production",
PORT: 5000,
@RyanDsilva
RyanDsilva / socket-proxylb-nginx.conf
Created July 6, 2020 20:27
SocketIO + Reverse Proxy + Load Balancing NGINX configuration file
upstream nodejs {
ip_hash;
server localhost:5000;
server localhost:5001;
}
server {
listen 80;
listen [::]:80;
server_name SERVER_IP;
@RyanDsilva
RyanDsilva / proxylb-nginx.conf
Created July 6, 2020 20:28
Reverse Proxy + Load Balancing NGINX configuration
upstream nodejs {
server localhost:5000;
server localhost:5001;
}
server {
listen 80;
listen [::]:80;
server_name SERVER_IP;
root /home/ryan;
@RyanDsilva
RyanDsilva / gzip-nginx.conf
Last active July 13, 2020 16:58
NGINX gzip compression
server {
...
...
gzip on;
gzip_types text/plain application/xml application/json;
gzip_comp_level 9;
gzip_min_length 1000;
...
@RyanDsilva
RyanDsilva / https-nginx.conf
Last active July 14, 2020 09:39
HTTPS configuration for NGINX
upstream nodejs {
ip_hash;
server localhost:5000;
server localhost:5001;
}
server {
listen 80;
listen [::]:80;
server_name DOMAIN_NAME;
@RyanDsilva
RyanDsilva / https-only-nginx.conf
Last active July 14, 2020 09:39
Only the HTTPS part of the configuration for NGINX
server {
listen 80;
listen [::]:80;
server_name DOMAIN_NAME;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
@RyanDsilva
RyanDsilva / dio_api_helper.dart
Created July 15, 2020 15:15
Flutter Dio Helper Class
import 'package:dio/dio.dart';
class ApiBaseHelper {
static final String url = 'BASE_URL';
static BaseOptions opts = BaseOptions(
baseUrl: url,
responseType: ResponseType.json,
connectTimeout: 30000,
receiveTimeout: 30000,
);
@RyanDsilva
RyanDsilva / lefthook.yaml
Created May 23, 2021 15:08
Lefthook YAML file for Flutter projects
pre-commit:
commands:
lint_code:
glob: '*.dart'
run: dart fix lib && git add .
format_code:
glob: '*.dart'
run: flutter format {staged_files} && git add .
pre-push:
@RyanDsilva
RyanDsilva / serverless.yml
Created August 26, 2021 19:03
AWS Step Functions serverless.yml
service: aws-step-functions
variablesResolutionMode: 20210326
provider:
name: aws
stage: ${opt:stage, 'dev'}
# profile: profile-name
region: eu-west-1
runtime: nodejs14.x
@RyanDsilva
RyanDsilva / try_catch.dart
Created June 26, 2022 09:14
Try-Catch and Error Handling in Flutter
import 'package:flutter/material.dart';
Future<dynamic> functionThatThrowsException() async {
// some code
throw Exception('Could not perform operation.');
}
Future<void> testFunction() async {
try {
var x = await functionThatThrowsException();