Skip to content

Instantly share code, notes, and snippets.

View manoelcampos's full-sized avatar
🙃
Finding a balance in the middle of chaos

Manoel Campos manoelcampos

🙃
Finding a balance in the middle of chaos
View GitHub Profile
@manoelcampos
manoelcampos / papers-authors-check-list.md
Last active June 1, 2018 13:23
A check list for authors of academic/scientific papers

List of common formatting, style standards and good practices to be applied in scientific papers writing

NOTE: The formatting standards can change depending of the publisher, which usually provide a style guide for authors. This list provides just the common standards usually accepted by the majority of publishers.

  • References for figures, tables, equations and source code listings usually start with capital letter. Examples:
    • the project follows a multi-tier architecture, as presented in Figure 1.
    • communication cost to migrate a virtual machine is computed by Equation 1.
  • Captions of figures, tables source code listings and so on have to finish with a dot, as any other phrase. Examples:
    • Figure 1. Overview of proposal architecture.
  • Algorithm 1. Proposed virtual machine migration algorithm.
@manoelcampos
manoelcampos / parse-intellij-code-duplication-report.sh
Last active April 14, 2023 08:42
Parses the HTML files generated by the 'Analyse > Locate Duplicates' tool of IntelliJ IDEA and them creates a csv file with summarised statistics. Pass to the script, the path of the directory where the IntelliJ reports were generated and it will parse everything
#!/bin/bash
clear
echo -e "Parses a directory with a set of HTML files with information about code duplication generated using IntelliJ IDEA 'Analyse > Locate Duplicates' tool.\n"
echo "The parser just analyses the directories starting with the word 'group'."
echo "Each dir represents the information about the duplication of a given code block, and just about that single block."
echo "A given dir contains HTML files that show where a specific block of code was duplicated."
echo "Each HTML in a dir shows where that block of code was duplicated, can be it across different source code files or in the same one."
@manoelcampos
manoelcampos / GenericComparableInheritanceProblem.java
Last active December 22, 2020 13:09
An example showing that it is not possible to implement a generic Comparable class that extends a super class and also ensures a clear code that is type safe and avoids surprising runtime typecast errors.
/**
* Example that shows <b>THE IMPOSSIBILITY</b> to implement {@link Comparable} for a given class
* and subclasses of it, ensuring that the {@code compareTo}
* method will receive an attribute of the current class where it is being
* implemented and not just a object from the super class, and yet providing a clear code.
* <b>Considering the classes {@link Foo} and {@link Bar} (this one a subclass from {@link Foo}).
* Thus, a class {@link Foo} must be compared just to {@link Foo} objects
* (that includes {@link Bar} objects) and a class {@link Bar} must be compared
* just to {@link Bar} objects.</b>
@manoelcampos
manoelcampos / Makefile
Last active April 21, 2017 20:51
A Makefile to compile tex documents (using pdf latex) which filters the overwhelming amount of logs and just shows error messages instead. Change the name of the tex file to compile at the first line of the script.
FILE=NAME-OF-THE-TEX-FILE-WITHOUT-EXTENSION-HERE
TEMP_FILE_EXTENSIONS=log aux lol lof loc soc lot bit idx glo bbl brf nlo nls ilg toc ind out blg synctex.gz snm nav dvi tdo spl
all: clean build
build:
make pdf
make bib
make pdf
make pdf
@manoelcampos
manoelcampos / latexdiff.sh
Last active April 21, 2017 20:56
A script to make it easy the utilization of the git latexdiff, a tool to generate a PDF comparing changes in a latex project across two different commits (https://gitlab.com/git-latexdiff/git-latexdiff). Run it without parameters to see the usage.
#!/bin/bash
clear
git latexdiff --version > /dev/null
RET=$?
if [ $RET -ne 0 ]; then
echo -e "\nInstall git-latexdiff using: git clone https://gitlab.com/git-latexdiff/git-latexdiff\n";
exit $RET;
fi
echo -e "git-latexdiff from https://gitlab.com/git-latexdiff/git-latexdiff\n"
@manoelcampos
manoelcampos / Option1.java
Last active May 16, 2020 18:58
A generic class that uses reflection to show how to get String values from an array and return such values converted to the generic type.
import java.lang.reflect.Constructor;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
public class Option1<T>{
private int length;
private String defaultValue;
private Class<T> klass;
@manoelcampos
manoelcampos / Option2.java
Last active February 17, 2018 22:46
A functional, generic class to show how to get String values from an array and return such values converted to the generic type.
import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.function.Function;
import java.lang.reflect.Array;
public class Option2<T>{
private int length;
private String defaultValue;
private final Function<String, T> conversionFunction;
@manoelcampos
manoelcampos / Option3.java
Last active February 17, 2018 22:43
A functional, generic class to show how to get String values from an array and return such values converted to the generic type. This class provides default implementations for converting from String to classes representing primitive types.
import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.function.Function;
import java.lang.reflect.Array;
public class Option3<T>{
private int length;
private String defaultValue;
private final Class<T> klass;
@manoelcampos
manoelcampos / bot.sh
Last active January 25, 2019 16:58
Sends a key and mouse click repeatedly, at a defined time interval
#!/bin/bash
# Sends a key and mouse click repeatedly, at a defined time interval.
# Author - Manoel Campos
clear
#Checks if xdotool command is installed. If not, installs it
xdotool -v 2>/dev/null || echo 'Installing required tools...' && sudo apt-get install xdotool -y > /dev/null
echo ''
@manoelcampos
manoelcampos / netbeans-macos-app-packager.sh
Last active June 4, 2019 00:08
A shell script to create a NetBeans.app package for macOS from the NetBeans binaries
#!/bin/bash
clear
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then
echo "
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a dir.
Usage: `basename "$0"` netbeans_dir
- netbeans_dir: The directory containing all the files for a specific NetBeans release.