Skip to content

Instantly share code, notes, and snippets.

View mguilherme's full-sized avatar
🎯
Focusing

Miguel Guilherme mguilherme

🎯
Focusing
View GitHub Profile
@mguilherme
mguilherme / pom.xml
Created July 24, 2013 23:12
Generates a jar with dependencies with maven shade plugin
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.guilherme.miguel</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
@mguilherme
mguilherme / pom.xml
Last active December 20, 2015 06:09
Jar with dependencies using maven-dependency-plugin
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.your.company</groupId>
<artifactId>test-artifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.7</java.version>
@mguilherme
mguilherme / gist:7119758
Created October 23, 2013 14:22
Extract Mail Recipients (name and mail) from a given String
public Map<String, String> extractRecipients(String content) {
content = StringEscapeUtils.unescapeXml(content);
Map<String, String> recipients = new HashMap<>();
Pattern pattern = Pattern.compile("(.*?)<([^>]+)>\\s*;?,?", Pattern.DOTALL);
Matcher matcher = pattern.matcher(content);
while(matcher.find()) {
String name = matcher.group(1).replaceAll("[\\n\\r\"]+", "").trim();
String email = matcher.group(2).replaceAll("[\\n\\r\\s\"]+", "").trim();
@mguilherme
mguilherme / x-editable-jquery.html
Created June 23, 2014 21:41
X-editable starter template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>X-editable starter template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/jquery-editable/css/jquery-editable.css" rel="stylesheet" />
<link href="//vitalets.github.io/x-editable/assets/poshytip/tip-yellowsimple/tip-yellowsimple.css" rel="stylesheet">
@mguilherme
mguilherme / Preferences.sublime-settings
Created December 20, 2015 16:25
Sublime User Preferences
{
"color_scheme": "Packages/User/SublimeLinter/primer.dark (SL).tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_size": 12,
"ignored_packages":
[
"Vintage"
],
"shift_tab_unindent": true,
"show_full_path": true,
@mguilherme
mguilherme / SpringTaskExecutor.java
Last active April 19, 2021 19:53
Start 5 tasks and wait until they finish (Spring AsyncTaskExecutor)
package com.guilherme.miguel;
import io.vavr.control.Try;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@mguilherme
mguilherme / TaskExecutor.java
Last active June 17, 2017 16:51
Start 5 tasks and wait until they finish
package com.guilherme.miguel;
import io.vavr.control.Try;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
@mguilherme
mguilherme / MatchCase.java
Created June 18, 2017 01:20
VAVR Match Case
package com.guilherme.miguel.vavr;
import com.guilherme.miguel.vavr.exception.AnotherException;
import com.guilherme.miguel.vavr.exception.OtherException;
import com.guilherme.miguel.vavr.exception.SomeException;
import io.vavr.control.Try;
import lombok.extern.slf4j.Slf4j;
import java.util.stream.IntStream;
@mguilherme
mguilherme / SpringRetry.java
Last active July 12, 2021 13:28
Spring Retry Examples
package com.guilherme.miguel.retry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.retry.RetryCallback;
import org.springframework.retry.RetryContext;
import org.springframework.retry.RetryListener;
@mguilherme
mguilherme / FailsafeRetry.java
Last active June 26, 2017 01:16
jodah Failsafe with Spring task executor
package com.guilherme.miguel.failsafe;
import lombok.extern.slf4j.Slf4j;
import net.jodah.failsafe.Failsafe;
import net.jodah.failsafe.RetryPolicy;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.task.AsyncTaskExecutor;