Skip to content

Instantly share code, notes, and snippets.

Avatar
⚙️
creating

Gabriele Boccarusso gabrieleboccarusso

⚙️
creating
View GitHub Profile
@gabrieleboccarusso
gabrieleboccarusso / BubbleSort.java
Created Jun 2, 2022
snipper for the java version of bubble sort
View BubbleSort.java
public class Main
{
public static void main(String[] args) {
int[] arr = {1,7,56,0,34,999};
boolean swapped = true;
int i;
while (swapped) {
swapped = false;
for (i = 0; i < arr.length - 1; ++i) {
@gabrieleboccarusso
gabrieleboccarusso / CompareObject.java
Created May 7, 2022
compare custom objects between each other
View CompareObject.java
// this is also useful for things like MyObj.contain(instance)
@Override
public boolean equals(Object compared) {
boolean flag = false;
if (this == compared) {
flag = true;
} else if (compared instanceof MyObj) {
Book comparedMyObj = (MyObj) compared;
@gabrieleboccarusso
gabrieleboccarusso / ReadFile.java
Created May 7, 2022
This gist contains the base snippet to read files in java
View ReadFile.java
import java.nio.file.Paths;
import java.util.Scanner;
public class ReadFile {
public static void main(String[] args) {
try (Scanner fileData = new Scanner(Paths.get("file.ext"))) {
while (fileData.hasNextLine()) {
current = fileData.nextLine();
if(!current.equals("")) {
// have fun
@gabrieleboccarusso
gabrieleboccarusso / templating.cpp
Last active May 7, 2022
quick snippet about cpp's templates
View templating.cpp
#include<iostream>
float division (float a, float b) {
return a / b;
}
template <class generic>
generic generic_division (generic a, generic b) {
return a / b;
}