Skip to content

Instantly share code, notes, and snippets.

View luizcarraro's full-sized avatar
🏠
Working from home

Luiz Carraro luizcarraro

🏠
Working from home
  • Pato Branco - BR
View GitHub Profile
@icebob
icebob / README.md
Last active October 22, 2023 19:50
Health-check middleware for Moleculer (for Kubernetes liveness readiness checks)
@tobydeh
tobydeh / moleculer-k8.md
Last active March 20, 2024 11:55
Moleculer k8 depoyment

Create a cluster on GKE:

gcloud container clusters create backend --num-nodes=2 --machine-type n1-standard-4

Get credentials:

gcloud container clusters get-credentials backend

Build the docker image:

@jeanlucaslima
jeanlucaslima / empresas.md
Last active October 20, 2017 13:46
Lusófonos usando Ember.js

Usuários de Ember.js

Ember logo

Empresas/apps/projetos brasileiros, portuguese e de outros locais que falam português e utilizam Ember.js.

Última atualização: 2017/maio

Brasil

import Vue from 'vue'
import {DataStore, Record} from 'js-data'
// define a base class that enables property-level vue reactivity.
export class VueReactiveRecord extends Record {
constructor (...args) {
// among other things, this will apply js-data schema if configured to do so; be sure to do `track: true`
super(...args)
@ivan-loh
ivan-loh / gist:ee0d96c3795e59244063
Last active March 3, 2021 13:26
Node.JS ( & pm2 ) Process Memory Limit
# Plain Ol' Node
node --max-old-space-size=1024 app.js # increase to 1gb
node --max-old-space-size=2048 app.js # increase to 2gb
node --max-old-space-size=3072 app.js # increase to 3gb
node --max-old-space-size=4096 app.js # increase to 4gb
node --max-old-space-size=5120 app.js # increase to 5gb
node --max-old-space-size=6144 app.js # increase to 6gb
# For pm2
pm2 start app.js --node-args="--max-old-space-size=1024" # increase to 1gb
@joewiz
joewiz / post-mortem.md
Last active September 3, 2023 11:57
Recovery from nginx "Too many open files" error on Amazon AWS Linux

On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:

2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files)

2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...

An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.

  1. * Instead of using su to run ulimit on the nginx account, use ps aux | grep nginx to locate nginx's process IDs. Then query each process's file handle limits using cat /proc/pid/limits (where pid is the process id retrieved from ps). (Note: sudo may be necessary on your system for the cat command here, depending on your system.)
  2. Added fs.file-max = 70000 to /etc/sysctl.conf

Publishing an NPM package

Here's what I do when I publish an NPM package.

1: Make sure you're up to date

I always like to check what's going on in a repo before I do anything:

@mphasize
mphasize / beforeCreate.js
Created March 2, 2015 10:10
Sails-beforeCreate-Policy
/**
* beforeCreate
*
* @module :: Policy
* @description :: Simple policy to inject the user creating a record into the records values.
* Assumes req.user && req.user.id to be set when a user is logged in.
* @docs :: http://sailsjs.org/#!documentation/policies
*
*/
@obolton
obolton / elb-nodejs-ws.md
Last active November 12, 2023 11:49
Configuring an AWS Elastic Load Balancer for a Node.js application using WebSockets on EC2

AWS ELB with Node.js and WebSockets

This assumes that:

  • You are using Nginx.
  • You want to accept incoming connections on port 80.
  • Your Node.js app is listening on port 3000.
  • You want to be able to connect to your Node.js instance directly as well as via the load balancer.

####1. Create load balancer

@goshmx
goshmx / htttp.js
Last active November 23, 2016 16:28
Fix Sails js error . Request entity too large. Code 413
//This fragment goes in your config/http.js file.
//Ensure to install skipper previusly...
//Tested in Sails.js v0.10.5
module.exports.http = {
bodyParser: (function () {
var opts = {limit:'50mb'};
var fn;