Skip to content

Instantly share code, notes, and snippets.

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

Marco Berri marcoberri

🏠
Working from home
View GitHub Profile
@marcoberri
marcoberri / InfluxDbImport.java
Created December 13, 2020 16:48
Sample import data into influx
package it.marcoberri.meteo;
import com.influxdb.annotations.Column;
import com.influxdb.annotations.Measurement;
import com.influxdb.client.InfluxDBClient;
import com.influxdb.client.InfluxDBClientFactory;
import com.influxdb.client.WriteApi;
import com.influxdb.client.domain.WritePrecision;
import com.influxdb.client.write.Point;
import org.apache.commons.io.IOUtils;
@marcoberri
marcoberri / SqlserveCheckIndex.sql
Created June 13, 2019 09:04
SqlServer - Check Index
SELECT dbschemas.[name] as 'Schema',
dbtables.[name] as 'Table',
dbindexes.[name] as 'Index',
indexstats.avg_fragmentation_in_percent,
indexstats.page_count,
'ALTER INDEX ' + dbindexes.[name] + ' ON ' + dbtables.[name] +' REBUILD;'
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS indexstats
INNER JOIN sys.tables dbtables on dbtables.[object_id] = indexstats.[object_id]
INNER JOIN sys.schemas dbschemas on dbtables.[schema_id] = dbschemas.[schema_id]
@marcoberri
marcoberri / nginx.conf
Created October 9, 2018 12:54
Configuration nginx for remove angular - FontAwensome version from url
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
@marcoberri
marcoberri / CacheRestObject.ts
Created August 20, 2018 12:43
Cache data on session storage by url with key
/**
*
* Verifica la presenza di un singolo valore in session storage,
* se non esiste esegue la chiamata
*
* @param {string} url
* @returns {*}
* @memberof ApiService
*/
public getLookUp(url: string): any {
@marcoberri
marcoberri / SpringSecurityoauth2SqlServer.sql
Created April 19, 2017 06:48
Spring Security oauth2 - SQLServer 2014 Table Script
USE [DBNAME]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
@marcoberri
marcoberri / wpscan.log
Created August 17, 2016 15:42
WpScan Example
root@kali:/usr/share/wordlists# wpscan --url www.<site>.com --enumerate u
_______________________________________________________________
__ _______ _____
\ \ / / __ \ / ____|
\ \ /\ / /| |__) | (___ ___ __ _ _ __
\ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \
\ /\ / | | ____) | (__| (_| | | | |
\/ \/ |_| |_____/ \___|\__,_|_| |_|
WordPress Security Scanner by the WPScan Team
@marcoberri
marcoberri / test_balancer_with_tomcat.txt
Last active November 26, 2019 13:05
(WP) test balancer apache 2.4 with two tomcat on debian
#su una Ubuntu 15.04 server
##Install java 8
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
##Verificare se è dispinibile la versione 2.4 di apache
@marcoberri
marcoberri / DropCollectionInDB.js
Last active February 9, 2016 11:03
MongoDB delete all collections in db with exclusion colleciton list
function deleteAllCollection(dbName,excludeCollection){
var dbOne = db.getSisterDB(dbName);
for(var colName in dbOne.getCollectionNames()){
var collectionName = dbOne.getCollectionNames()[colName];
if(!collectionName || collectionName == "")
continue;
if(excludeCollection.indexOf(collectionName) > -1)
continue;
dbOne[collectionName].drop();
@marcoberri
marcoberri / PurgeLogCollection.js
Last active February 4, 2016 16:51
Esegue una eliminazione di dati in tutte le collection contente i log eseguendo il controllo sul campo data chiamato "ts"
/*
la funzioanlità ricerca nel server tutti i db like <db_like_name> e per ogni collecion presente nel singolo db
esegue una eliminazione per spurgare i log.
per eseguire lo script
./mongo --host <indirizzo_host> --port <porta> PurgeLogCollection.js --quiet --eval "var deleteData=false;var beforePurgeDay=200;"
parametri in eval
deleteDate = true|false (se false visualizza solo questo che dovrà fare senza eliminare default false)
@marcoberri
marcoberri / MongoScriptUtils.js
Created February 4, 2016 11:16
Script Utils for Mongo DB
function bytesToSize(bytes, precision) {
var kilobyte = 1024;
var megabyte = kilobyte * 1024;
var gigabyte = megabyte * 1024;
var terabyte = gigabyte * 1024;
if ((bytes >= 0) && (bytes < kilobyte)) {
return bytes + ' B';
} else if ((bytes >= kilobyte) && (bytes < megabyte)) {