Skip to content

Instantly share code, notes, and snippets.

View ldaniel's full-sized avatar
🏠
Working from home

Leandro Daniel ldaniel

🏠
Working from home
View GitHub Profile
@ldaniel
ldaniel / loadContent.htm
Created February 18, 2012 16:23
Load page response content
<!DOCTYPE html>
<html>
<head>
<title>Load</title>
<script type="text/javascript" src="scripts/jquery-1.7.1.min.js"></script>
</head>
<body>
<b>Response:</b>
<div id="success"></div>
<br />
@ldaniel
ldaniel / MultipleCatchBlocks.java
Created February 1, 2012 12:32
Multiple catch blocks
try {
// codigo que pode gerar IOException
}
catch (FileNotFoundException e){
// tratamento
}
catch (IOException e){
// tratamento
}
@ldaniel
ldaniel / catchingExceptions.cs
Created January 31, 2012 12:12
Essa não! Catching Exception de novo!
try
{
// codigo que pode gerar uma exception
}
catch(Exception ex)
{
Logger.Log(ex);
}
@ldaniel
ldaniel / exceptionSample2.pas
Created January 30, 2012 18:28
Manipulando exceções em Delphi 4.0
procedure TForm1.FormCreate(Sender: TObject);
var
Buffer : Pointer;
begin
Buffer := AllocMem(1024);
try
{ Codigo que pode gerar uma excecao }
finally
FreeMem(Buffer);
end;
@ldaniel
ldaniel / exceptionsample.rb
Created January 30, 2012 15:28
Tratando erros no Ruby
tarifacao = File.open(arquivo, "w")
begin
# excecoes serao capturadas apos o 'begin'
while data = socket.read(512)
tarifacao.write(data)
end
# Trata alguma excecao
rescue SystemCallError
@ldaniel
ldaniel / ExceptionSample.java
Created January 25, 2012 19:04
Tratando erros no Java
public void openFile(){
try {
FileReader reader = new FileReader("arquivo.txt");
int i=0;
while(i != -1){
i = reader.read();
System.out.println((char) i );
}
reader.close();
System.out.println("-> EOF");
@ldaniel
ldaniel / ExceptionSample.pas
Created January 25, 2012 18:48
Tratando erros no Delphi
var
saldo, indice : Integer;
begin
try
indice := 0;
saldo := 1;
saldo := saldo div indice;
ShowMessage('1 / 0 = ' + IntToStr(saldo));
@ldaniel
ldaniel / ExceptionSample.vb
Created January 23, 2012 21:43
Tratando erros no Visual Basic 6
Sub InitializeMatrix(Var1, Var2, Var3, Var4)
On Error GoTo ErrorHandler
' algum codigo aqui
Exit Sub
ErrorHandler:
@ldaniel
ldaniel / NadaDeIFs.cs
Created April 12, 2011 16:15
Usando IFs, o certo e o errado.
using System;
namespace NadaDeIfs
{
class Program
{
static void Main(string[] args)
{
IFuncionario funcionario = new Funcionario();
AplicarBonus(funcionario);