Skip to content

Instantly share code, notes, and snippets.

View xlbruce's full-sized avatar
💭
Adena plz

Gilson de Paula xlbruce

💭
Adena plz
View GitHub Profile
@xlbruce
xlbruce / CalculateDuration.java
Created July 5, 2016 20:40
Get a human readable String representing a period between 2 dates
private static String getStringDuration(Temporal startDate, Temporal endDate){
Duration d = Duration.between(startDate, endDate);
StringBuilder str = new StringBuilder();
long total = d.getSeconds();
long days = total / DAYS;
if (days > 0) {
str.append(days)
.append("d ");
total -= days * DAYS;
@xlbruce
xlbruce / Plugin surefire
Created June 6, 2016 17:56
Sometimes, tests pass fine on Eclipse, but fail on Maven Surefire
http://stackoverflow.com/questions/3365628/junit-tests-pass-in-eclipse-but-fail-in-maven-surefire
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<reuseForks>false</reuseForks>
<forkCount>1</forkCount>
</configuration>
@xlbruce
xlbruce / Sonar build.txt
Created May 19, 2016 17:13
Maven command to build, test and add a project on Sonarqube
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Pcoverage-per-test && mvn sonar:sonar -Dsonar.host.url=http://localhost:9000
@xlbruce
xlbruce / SimpleHTTPServerWithUpload.py
Created May 11, 2016 18:29 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@xlbruce
xlbruce / get-param.js
Created February 24, 2016 21:20
Gets a param in a query string (JavaScript)
function get(name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
}
@xlbruce
xlbruce / TIAValidator.java
Last active February 18, 2016 17:05
Faz a validação do TIA (Terminal Informativo do Aluno) do Mackenzie
package com.validator;
/**
* Faz a validação do TIA (Terminal Informativo do Aluno) do Mackenzie
* @author gilson
*/
public class TIAValidator {
private static final byte[] nums = {8, 7, 6, 5, 4, 3, 2};
@xlbruce
xlbruce / put_variables.php
Created February 16, 2016 17:17
Get variables sent by client using PUT/DELETE verbs
<?php
parse_str(file_get_contents('php://input'), $vars); //Recebe as variaveis e guarda na variavel $vars
var_dump($vars); //Verifica as variáveis recebidas
?>
@xlbruce
xlbruce / Tutorial pos instalacao.txt
Created November 7, 2015 12:18
Tutorial pós-instalação de um sistema GNU/Linux (preferencialmente Debian)
Este documento tem por objetivo fornecer instruções para deixar o sistema completo após a instalação do mesmo.
1. Pacotes essenciais
ethtool: útil para identificar se a interface de rede está recebendo sinal por um cabo de rede. Possui a mesma função do comando mii-tool.
less: um filtro que permite a leitura de arquivos longos diretamente na tela.
mc: o mc contém os programas Midnight Commander (mc) e mcedit. O mcedit é o editor de textos mais amigável para ambiente shell.
tcpdump: utilizado para resolver problemas quando a máquina estiver operando em redes de computadores.
Para instalar esses pacotes:
@xlbruce
xlbruce / Lab - Matrizes
Created September 19, 2015 19:47
Conferir os métodos!
package matrizes;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
/**
*
* @author bruce
*/
@xlbruce
xlbruce / Criação das tabelas.sql
Created September 16, 2015 00:05
Sistema de emprestimo (LP3)
CREATE TABLE livro (
id INT NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
nome VARCHAR(30)
);
CREATE TABLE amigo (
id INT NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
nome VARCHAR(30),
telefone VARCHAR(9)
);