Skip to content

Instantly share code, notes, and snippets.

@dinolupo
dinolupo / maven.sh
Created August 21, 2016 08:09
Maven Javadoc And Sources
# When you’re using Maven in an IDE you often find the need for your IDE to resolve source code and Javadocs for your library dependencies. There’s an easy way to accomplish that goal.
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
# The first command will attempt to download source code for each of the dependencies in your pom file.
# The second command will attempt to download the Javadocs.
# Maven is at the mercy of the library packagers here. So some of them won’t have source code packaged and many of them won’t have Javadocs.
@dinolupo
dinolupo / Ubuntu-16.04-Developer-Settings.md
Last active March 19, 2017 18:57
Fresh Install of Ubuntu 16.04 LTS

install missing softwares

sudo apt-get -y install vim git zsh tree ack-grep npm guake tmux

install Ubuntu Firewall GUI

sudo apt-get -y install gufw

openjdk and mongodb

sudo apt-get -y install openjdk-8-jdk mongodb

@dinolupo
dinolupo / TestWebException.java
Last active October 30, 2017 09:33
How to manage Exceptions in Java EE Rest Services .
import javax.ejb.ApplicationException;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
/**
*
* @author Dino Lupo
*/
@ApplicationException(rollback = true)
public class TestWebException extends WebApplicationException {
@dinolupo
dinolupo / JsonSample.java
Last active October 31, 2017 11:52
JSON Collectors are useful when working with streams and filtering a JsonArray with a results into another JsonArray. In the example below you are filtering for a female gender and creating a JsonArray with all the selected names.
JsonArray contacts = ...;
JsonArray femaleNames =
contacts.getValuesAs(JsonObject.class).stream()
.filter(x->"F".equals(x.getString("gender")))
.map(x->(x.getString("name"))
.collect(JsonCollectors.toJsonArray());
@dinolupo
dinolupo / gist.md
Created November 1, 2017 07:20 — forked from benbalter/gist.md
Example of how to embed a Gist on GitHub Pages using Jekyll.

Here's an example of how to embed a Gist on GitHub Pages:

{% gist 5555251 %}

All you need to do is copy and paste the Gist's ID from the URL (here 5555251), and add it to a gist tag surrounded by {% and %}.

Keeping your site up to date with the GitHub Pages gem

bundle update github-pages

Build your local Jekyll site

bundle exec jekyll serve

Car car1 = new Car();
car1.setMake("Toyota");
car1.setModel("Prius");
car1.setStock("20");
Car car2 = new Car();
car2.setMake("Tesla");
car2.setModel("Model S");
car2.setStock("2");
List<Car> inventory = new ArrayList<>();
@dinolupo
dinolupo / .vimrc
Last active September 26, 2018 19:11
VIMRC
syntax on
:colorscheme darkblue
:set tabstop=4
:set shiftwidth=4
":set expandtab
" Clear last search highlighting
nnoremap <Space> :noh<cr>
" If arrows key not working do the following
@dinolupo
dinolupo / .dircolors
Created May 16, 2015 18:11
.DIRCOLORS I really do not like those blue folders on Linux
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copying and distribution of this file, with or without modification,
# are permitted provided the copyright notice and this notice are preserved.
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
# Below, there should be one TERM entry for each termtype that is colorizable
TERM Eterm
TERM ansi
#!/usr/bin/env bash
####################################################
# Ubuntu Linux configuration for WSL 2 #
# Author: Dino Lupo #
# Release Date: 2020/08/30 #
####################################################
# Install Ubuntu latest with WSL version 2
# then launch it and copy this file in Ubuntu with
#