Skip to content

Instantly share code, notes, and snippets.

View alexandregama's full-sized avatar

Alexandre Gama alexandregama

View GitHub Profile
@alexandregama
alexandregama / gist:703910
Created November 17, 2010 19:36
TDD simples e prático, Parte III
//Este código faz parte do artigo em http://alexandregama.wordpress.com
//Classe de Teste utilizando JUnit 4
package artigotdd.calculadora.teste;
import static org.junit.Assert.*;
import org.junit.Test;
public class CalculadoraTeste {
@alexandregama
alexandregama / gist:704721
Created November 18, 2010 07:21
Primeiro exemplo de Servlets - Apostila Caelum
//web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>caelum</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
@alexandregama
alexandregama / gist:747582
Created December 19, 2010 18:50
Algoritmo: Código simples resolvendo um problema de divisão, em Java
//Código que faz parte do artigo para iniciantes em www.alexandregama.wordpress.com
//Primeira versão
import java.util.Scanner;
public class DivisaoDeNumeros {
public static void main(String[] args) {
//Criamos um objeto Scanner para capturar o que foi digitado
Scanner input = new Scanner(System.in);
@alexandregama
alexandregama / gist:747608
Created December 19, 2010 19:21
Algoritmo: Código simples resolvendo um problema de divisão, em C
//Código que faz parte do artigo para iniciantes em www.alexandregama.wordpress.com
#include<stdio.h>
#include<stdlib.h>
int main() {
//Declaração das variáveis para guardar os valores
int dividendo;
int divisor;
@alexandregama
alexandregama / gist:1499695
Created December 20, 2011 00:58
JSON Simples e Prático, Parte I
package br.com.json;
public class Carro {
private Long id;
private String modelo;
private String placa;
public Long getId() {
return id;
}
@alexandregama
alexandregama / gist:1894280
Created February 23, 2012 18:43
JSON Simples e Prático, Parte II
/* Código que faz parte do artigo http://alexandregama.wordpress.com/2012/02/23/json-simples-e-pratico-parte-ii/ */
/* Classe Http */
package br.com.artigo.json;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
@alexandregama
alexandregama / gist:2359232
Last active October 3, 2015 00:58
Install JDK6 for Programmers
//First, add repository for JDK6
sudo add-apt-repository ppa:ferramroberto/java
//Now get update with the command
sudo apt-get update
//Then, install JDK6 with the command below
sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
//Simple! Go ahead!
Create EC2 Instance with Ubuntu Server (choose defaulf security group)
Generate Key Par and download the file
Open "Security Groups", select "default" group, choose SSH rule and add the source "0.0.0.0/0" (press Add rule and Apply rule changes)
Open SSH Client (SSH Cliente for Ubuntu or Putty for Windows)
Set special permission on file
chmod 400 yourkeypar.pem
@alexandregama
alexandregama / gist:3710832
Created September 12, 2012 23:49
Departamento
public class Departamento {
public void calculaNotaFiscal() {
// seu código para calculo da nota fiscal
}
public void calculaPagamentoDeFuncionarios() {
// seu código para cálculo do pagamento
}
public void calculaNotaFiscal() {
// seu código para calculo da nota fiscal
}
public void calculaPagamentoDeFuncionarios() {
// seu código para cálculo do pagamento
}
public void verificaInadimplenciaDeClientes() {
// seu código para a verificação de inadimplência