Skip to content

Instantly share code, notes, and snippets.

View GaetanoPiazzolla's full-sized avatar
🎯
Focusing

Gaetano Piazzolla GaetanoPiazzolla

🎯
Focusing
View GitHub Profile
@GaetanoPiazzolla
GaetanoPiazzolla / avgLoad.js
Last active May 20, 2024 07:13
% CPU in Node.JS
const os = require("os");
//Create function to get CPU information
function cpuAverage() {
//Initialise sum of idle and time of cores and fetch CPU info
var totalIdle = 0, totalTick = 0;
var cpus = os.cpus();
//Loop through CPU cores
@GaetanoPiazzolla
GaetanoPiazzolla / docker-compose.yml
Created February 20, 2020 11:58
GrayLog + MongoDB
version: '2'
services:
mongodb:
image: mongo:3
volumes:
- /data/graylog/mongo_data:/data/db
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.2
volumes:
- /data/graylog/es_data:/usr/share/elasticsearch/data:rw
@GaetanoPiazzolla
GaetanoPiazzolla / .gitconfig
Last active October 14, 2020 16:36
The best GIT aliases ever
[user]
name = gpiazzolla
email = gae.xx@gmail.com
[alias]
search = ! git branch -a | sed '/->/d' | sed 's/\\*//' | xargs git grep -n -I
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
last = log -1 head
rehard = reset --hard
branches = branch -la
@GaetanoPiazzolla
GaetanoPiazzolla / CamelInsensitivePath.java
Last active October 20, 2020 17:13
Recursive Camel Insensitive Java File Discovery ( Java 1.8 )
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
@GaetanoPiazzolla
GaetanoPiazzolla / entry.json
Last active October 21, 2020 07:03
HAR entry example
{
"request": {
"method": "GET",
"url": "http://www.softwareishard.com/blog/har-12-spec/",
"httpVersion": "HTTP/1.1",
"headers": [ ],
"cookies": [ ]
},
"response": {
"status": 200,
@GaetanoPiazzolla
GaetanoPiazzolla / ddl.sql
Last active January 6, 2021 19:04
Simple postgresql database for testing purpose
CREATE SCHEMA library
AUTHORIZATION postgres;
CREATE SEQUENCE library.books_book_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;
@GaetanoPiazzolla
GaetanoPiazzolla / timecmd.bat
Created February 26, 2021 18:28
Log time execution of Windows CMD
@echo off
@setlocal
set start=%time%
:: Runs your command
cmd /c %*
set end=%time%
set options="tokens=1-4 delims=:.,"
@GaetanoPiazzolla
GaetanoPiazzolla / Easter.java
Created April 4, 2021 13:19
Calculate easter
import java.time.LocalDate;
public class Easter{
public static void main(String []args){
System.out.println(HelloWorld.getEasterOfYear(2021));
}
private static LocalDate getEasterOfYear(int y) {
const calculus = require('./calculus')
const asynch_calculus = (num) => {
return new Promise((resolve, reject) => {
resolve(calculus.execute(num))
})
}
const execute = (num) => {
let result = 0;
for (let i = Math.pow(num, 7); i >= 0; i--) {
result += Math.atan(i) * Math.tan(i);
}
return result;
}
module.exports = {
execute