Skip to content

Instantly share code, notes, and snippets.

View neo7BF's full-sized avatar
😃

Alessandro Forcuti neo7BF

😃
View GitHub Profile
@neo7BF
neo7BF / Main.java
Created April 5, 2020 14:51
Read and Write Objects in java with SerializationUtils of Apache Commons
package it.neo7bf.serialization;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import org.apache.commons.lang3.SerializationUtils;
/**
@neo7BF
neo7BF / LoggingExecutionTimeQueryAspect.java
Last active August 11, 2020 09:33
Misuring execution time of queries with spring aop and spring jdbc in spring boot
@Component
@Aspect
@Slf4j
public class LoggingExecutionTimeQueryAspect {
//replace <> with your own repository class info for tracing execution time of queries of that Repository
private Temporal startTime;
@Before("execution(* <PACKAGE>.<RESPOSITORY_CLASS_NAME>.*(..))")
public void logBeforeQueryInvocation(JoinPoint joinPoint){
startTime = Instant.now();
@neo7BF
neo7BF / LoggingExecutionTimeQueryAspect.java
Last active August 11, 2020 09:34
Another structured way to trace execution time of queries with spring aop and spring jdbc in spring boot
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
//Replate <> with your package
@Component
@Aspect
@neo7BF
neo7BF / main.py
Created January 17, 2021 13:43
Search in matrix with Phyton
w, h = 8, 5;
# le prime due quadre interne creano un array di W posti riempito di zeri (asse x), questo stesso array è poi usato come valore per riempire H posti (asse y) formando una matrice bidimensionale.
MatrixTest1 = [[0 for x in range(w)] for y in range(h)]
MatrixTest2 = [[0 for x in range(w)] for y in range(h)]
MatrixTest3 = [[0 for x in range(w)] for y in range(h)]
MatrixTest1[0][0] = 2
MatrixTest1[0][1] = 2
MatrixTest1[4][6] = 3
@neo7BF
neo7BF / HowToUsePointers.java
Last active January 30, 2021 10:55
Related to my article on the use of the pointers in C++
#include <iostream>
using namespace std;
int main()
{
/*
Il calcolatore assegna ad A l’indirizzo della cella di memoria 0x00
e memorizza il valore 5
*/
@neo7BF
neo7BF / ManageDeviceInputFromPowershell.ps1
Created February 25, 2021 15:46
Devices input management from powershell
####################
# KEYBOARD VERSION #
####################
$shell = New-Object -ComObject WScript.Shell
while(1) {
$shell.sendkeys("{NUMLOCK}{NUMLOCK}")
$time = Get-Date;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class GenericsAndResultSet {
public static void main(String[] args) {
int A = 5;
cout << &A; // print on screen 0x00 (in a real computer the address will be different)
int* B = &A;