Skip to content

Instantly share code, notes, and snippets.

View dorfo-dev's full-sized avatar
🎯
Focusing

Rodolfo Capellini dorfo-dev

🎯
Focusing
View GitHub Profile
@lucasdzuc
lucasdzuc / lista-projetos-nodeteam.md
Last active May 5, 2022 16:27
LISTA DE PROJETOS ENVENTO NODE TEAM 1° EDIÇÃO

1 - Projeto Agendamento de Serviço

Requisitos:

Desenvolver uma API Node com autenticação JWT ou outro tipo de autenticação caso ache melhor.

Prestador de serviço poderá se cadastrar no sistema com os seguintes atributos. Nome Completo, E-mail, Senha, Role: "Prestador" (tipo de usuário como prestador de serviço).

O prestador de serviço poderá cadastrar seus serviços no sistema com os seguintes atributos:

@nicolasmelo1
nicolasmelo1 / asynchronous.py
Created February 25, 2021 14:34
Exemplo de uso de threads para assincronia em um sistema Django SEM O CELERY
# ESSE CODIGO FICA DENTRO DO SERVER
import threading
from django.conf import settings
# limita o numero de threads rodando em paralelo.
semaphore = threading.BoundedSemaphore(
value=settings.ASYNC_RESPONSE_MAXIMUM_CONCURRENCY_THREADS
)
@crgeary
crgeary / inertia.js
Last active March 27, 2024 09:00
Inertia adapter for Express
const lodashPick = (object, keys) => {
return keys.reduce((obj, key) => {
if (object && object.hasOwnProperty(key)) {
obj[key] = object[key];
}
return obj;
}, {});
};
const setupProps = async (props) => {
@yovko
yovko / ohmyzsh.md
Last active June 19, 2024 06:18
ZSH (using Oh My ZSH) on Manjaro Linux

ZSH (using Oh My ZSH) on Manjaro Linux

0. If ZSH is not already installed on your Manjaro system you can do it with the command:

sudo pacman -Syu zsh

You do not need to install manjaro-zsh-config and all the other related packages like zsh-syntax-highlighting, zsh-history-substring-search, zsh-autosuggestions, etc., as we will use Oh My Zsh.

@max-rocket-internet
max-rocket-internet / prom-k8s-request-limits.md
Last active June 5, 2024 02:27
How to display Kubernetes request and limit in Grafana / Prometheus properly

CPU: percentage of limit

A lot of people land when trying to find out how to calculate CPU usage metric correctly in prometheus, myself included! So I'll post what I eventually ended up using as I think it's still a little difficult trying to tie together all the snippets of info here and elsewhere.

This is specific to k8s and containers that have CPU limits set.

To show CPU usage as a percentage of the limit given to the container, this is the Prometheus query we used to create nice graphs in Grafana:

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container_name!="POD"}[5m])) by (pod_name, container_name) /
@lukecav
lukecav / ngnix.config
Last active May 14, 2023 13:46
Browser caching rules for NGNIX and expire headers.
# Browser caching of static assets.
location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf)$ {
expires 7d;
add_header Cache-Control "public, no-transform";
}
# Media: images, icons, video, audio send expires headers
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm)$ {
expires 1M;
access_log off;
@pmuellr
pmuellr / cpu-percent.js
Created April 12, 2016 14:59
get CPU usage percent for a process in node, using proposed `process.cpuUsage()` function
'use strict'
// see: https://github.com/nodejs/node/pull/6157
var startTime = process.hrtime()
var startUsage = process.cpuUsage()
// spin the CPU for 500 milliseconds
var now = Date.now()
while (Date.now() - now < 500)
@amalgjose
amalgjose / DateDifference.py
Last active January 4, 2022 19:02
This is a very simple python code snippet for calculating the difference between two dates or timestamps. This will calculate the difference in terms of number of years, months, days, hours, minutes etc. For more details, refer https://amalgjose.com/2015/02/19/python-code-for-calculating-the-difference-between-two-time-stamps/
__author__ = 'Amal G Jose'
from datetime import datetime
from dateutil import relativedelta
##Aug 7 1989 8:10 pm
date_1 = datetime(1989, 8, 7, 20, 10)
##Dec 5 1990 5:20 am
date_2 = datetime(1990, 12, 5, 5, 20)
@lancejpollard
lancejpollard / node-folder-structure-options.md
Created November 28, 2011 01:50
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