Skip to content

Instantly share code, notes, and snippets.

View willianantunes's full-sized avatar
🎯
Focusing

Willian Antunes willianantunes

🎯
Focusing
View GitHub Profile
class HttpService {
get(url) {
return new Promise((resolve, reject) => {
let xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onreadystatechange = () => {
import br.com.willianantunes.serenata.JarbasAPI;
import br.com.willianantunes.support.ScenarioBuilder;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Producer;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.ExchangeBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.cxf.common.message.CxfConstants;
import org.apache.camel.component.cxf.jaxrs.CxfRsBinding;
import java.io.IOException;
import java.util.Collection;
import org.hibernate.Hibernate;
import org.hibernate.proxy.HibernateProxy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
package br.com.willianantunes.playground;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.PropertyInject;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.twitter.search.TwitterSearchComponent;
import org.apache.camel.model.ModelCamelContext;
@willianantunes
willianantunes / pk-limit-solution.sql
Created October 21, 2017 22:53
SQL file used for my blog post
-- 1 - Criar/copiar tabela problemática:
CREATE TABLE TABELA_NOVA SELECT * FROM TABELA_PRODUCAO;
-- 2 - Obter último valor da PK, nosso caso 65535
SELECT PK_ABUDEGA FROM TABELA_PRODUCAO ORDER BY PK_ABUDEGA DESC;
-- 3 - Adicionar constraints necessárias e obviamente da PK também
ALTER TABLE TABELA_NOVA ADD PRIMARY KEY (PK_ABUDEGA);
ALTER TABLE TABELA_NOVA CHANGE PK_ABUDEGA PK_AJUSTADA INT(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE TABELA_NOVA ADD FOREIGN KEY (TABELA_RELACIONADA_ID) REFERENCES TABELA_RELACIONADA(ID);
-- 4 - O valor do passo 3 mais 1
ALTER TABLE TABELA_NOVA AUTO_INCREMENT = 65536;
@willianantunes
willianantunes / MyFunctionalPostBlog.java
Last active June 1, 2017 11:33
Class used for my blog post
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.Month;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Matcher;
@willianantunes
willianantunes / TwitterSnifferRoute.java
Created May 31, 2017 19:01
Class used for my blog post
package br.com.willianantunes.test.routes;
import java.time.LocalDateTime;
import java.time.ZoneId;
import org.apache.camel.LoggingLevel;
import org.apache.camel.PropertyInject;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jackson.JacksonDataFormat;
import org.apache.camel.component.twitter.TwitterComponent;
package br.com.willianantunes.analyser;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
#!/bin/bash
# Checks the requests status available in an access.log file and outputs the first 20 lowest responses.
# The following pattern is expected: '%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i" %Dms'
# Author: Thiago Ferreira (https://github.com/tfc1304)
# Example of command to use it: ./check-access-log.sh '/my-path/services/rest/users' '/tmp/access_log.2017-03-03'
RED='\033[0;31m'
BLUE='\033[1;34m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
package br.com.willianantunes.utils;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.joda.time.DateTimeConstants;
import org.joda.time.LocalDate;
/**