Skip to content

Instantly share code, notes, and snippets.

View AlexRNL's full-sized avatar

Alex Barféty AlexRNL

View GitHub Profile
@AlexRNL
AlexRNL / backup_duplicity.sh
Created March 16, 2020 14:31
Useful shell scripts
#!/bin/bash
# Script backup-duplicity.sh
# --------------------------
# Perform a backup of the current machine using duplicity and synchronize it to a remote machine
# Abort on unset variables
set -o nounset
## Global variables
@AlexRNL
AlexRNL / .gitconfig
Created March 16, 2020 14:18
Git configuration
[user]
name = Alex
email = alex@example.com
username = alex
[color]
ui = true
[help]
autocorrect = 20
@AlexRNL
AlexRNL / .vimrc
Created March 16, 2020 14:16
Vim configuration files
"Basic settings
set bg=dark
colorscheme slate
set nocompatible
set nopaste
set pastetoggle=<F9>
"Setting indentation
set autoindent smartindent
set shiftwidth=4
set expandtab
@AlexRNL
AlexRNL / .bash_aliases
Created March 16, 2020 14:07
bash configuration files
#!/bin/bash
# Aliases definition file
# -----------------------
# Enable color support of ls, grep, ip, etc.
aliases_color () {
if [[ -x /usr/bin/dircolors ]] ; then
local dircolors_file=""
if [[ -r ~/.dircolors ]] ; then
@AlexRNL
AlexRNL / MathUtils.java
Last active August 29, 2015 14:12
Method to compute the maximum in a collection of number
public class MathUtils {
/**
* Return the maximum number in a collection.<br />
* @param collection
* the collection.
* @return the maximum value in the collection or <code>null</code> if the collection is empty.
*/
public static <T extends Number> T max (Iterable<T> collection) {
T max = null;
for (T item : collection) {
@AlexRNL
AlexRNL / EndOfLineDocToJavadoc
Last active March 30, 2016 16:30
Java parsing regexp
Find: "^(\s+)(.*;)\s+\/\*\*?(.*)$"
Replace with: "\1/**\3\n\1\2"
@AlexRNL
AlexRNL / gist:6219859
Last active December 21, 2015 00:28 — forked from hay/gist:1351230
<!doctype html>
<html>
<head>
<title></title>
<style>
body {
background: white;
text-align: center;
padding: 20px;
font-family: Georgia, serif;
@AlexRNL
AlexRNL / UIManagerColorKeys.java
Created June 30, 2013 18:53
Snippet for generating the list of color keys availble in Swing's UIManager.
package com.sun.test;
import java.awt.Color;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.logging.Logger;
import javax.swing.UIManager;
@AlexRNL
AlexRNL / clean-upProfile.xml
Created April 8, 2013 13:17
XML configuration files for a proper Eclipse clean-up, template and formatter configuration.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="2">
<profile kind="CleanUpProfile" name="Perso" version="2">
<setting id="cleanup.format_source_code" value="true"/>
<setting id="cleanup.add_missing_annotations" value="true"/>
<setting id="cleanup.use_this_for_non_static_method_access_only_if_necessary" value="true"/>
<setting id="cleanup.remove_unused_private_types" value="true"/>
<setting id="cleanup.qualify_static_member_accesses_through_instances_with_declaring_class" value="true"/>
<setting id="cleanup.qualify_static_method_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.add_generated_serial_version_id" value="false"/>
@AlexRNL
AlexRNL / SleepPrevent.java
Last active December 15, 2015 20:29
Utility to avoid a computer to go to sleep.
package sleep_prevent;
import java.awt.AWTException;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Robot;
import java.util.logging.Level;
import java.util.logging.Logger;