Skip to content

Instantly share code, notes, and snippets.

View thiagotn's full-sized avatar

Thiago Nogueira thiagotn

View GitHub Profile
package testes;
import java.util.Arrays;
public class MesclaArrays {
public static void main(String[] args) {
int primeiro[] = {1,4,7,9,6};
int segundo[] = {2,3,5,8,10};
int terceiro[] = new int[primeiro.length + segundo.length];
@thiagotn
thiagotn / TestReflection.java
Created September 21, 2011 15:40
Bean to CVS
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class TestReflection {
public static void main(String args[]) {
List<Usuario> usuarios = new ArrayList<Usuario>();
for ( int i=0 ; i<10 ; i++) {
@thiagotn
thiagotn / WriteCsv.java
Created September 29, 2011 12:48
Write Csv Content
public class WriteCsv {
public static String writeCsvContent(String[][] data) {
StringBuilder csv = new StringBuilder();
String delimiter = ",";
String breakLine = "\n";
for (int line = 0; line < data.length; line++) {
for (int column = 0; column < data[line].length; column++) {
csv.append(data[line][column]);
if (column < data[line].length-1) csv.append(delimiter);
@thiagotn
thiagotn / CsvUtil.java
Created April 11, 2012 19:30
Csv Util
package migrator.util;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import com.google.common.base.Charsets;
import com.google.common.base.Strings;
@thiagotn
thiagotn / InverteUrl.java
Created April 30, 2012 06:55
InverteUrl
public class InverteUrl {
public static void main(String args[]) {
if (args.length == 0) {
throw new IllegalArgumentException("Cadê a url?");
}
String url = args[0];
int len = url.length();
@thiagotn
thiagotn / MeuBroadcast.java
Created December 10, 2015 21:37
BroadcastReceiver
package br.com.heiderlopes.democomponentesandroid.broadcast;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.telephony.TelephonyManager;
import android.util.Log;
@thiagotn
thiagotn / Calculator.java
Last active January 29, 2016 21:09
Calculator Simples
import java.util.Arrays;
import java.util.List;
public class Calculator {
public static void main(String[] args) {
Calculator calculator = new Calculator();
//Double result = calculator.calcWithArray(Arrays.asList("5", "*", "4", "+", "2", "-", "9", "+", "7", "/", "2")); // 10
Double result = calculator.calcWithArray(Arrays.asList("1", "/", "0"));
System.out.println(result);
import static org.junit.Assert.*;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import dev.util.inscriptions.Calculator;
public class CalculatorTest {
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.6</version>
<executions>
<execution>
<id>generate-docs</id>
<phase>prepare-package</phase>
<goals>
<goal>process-asciidoc</goal>
package com.example.demoapi.products
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.servlet.support.ServletUriComponentsBuilder
import java.net.URI
@RequestMapping("/products")
@RestController
class ProductsController(private val service: ProductsService) {