Skip to content

Instantly share code, notes, and snippets.

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

Leonardo Cordeiro leonardocordeiro

🏠
Working from home
  • Rio de Janeiro, RJ
View GitHub Profile
#include <stdio.h>
main(){
int i;
for(i = 0; i < 5; i++){
getchar();
fflush(stdin);
}
}
@leonardocordeiro
leonardocordeiro / Example.java
Last active August 29, 2015 14:01
Method Reference Example
import java.util.*;
import java.util.function.*;
class Example {
public static void main(String[] args) {
List<String> names = Arrays.asList("Leonardo", "John", "Maria");
names.sort(Comparator.comparing(Function.identity()));
Consumer<String> consumer = System.out::println;
@leonardocordeiro
leonardocordeiro / gist:b36ef5767538fe770eef
Last active August 29, 2015 14:02
maior elemento diagonal principal, soma diagonal secundária
#include <stdio.h>
#include <stdlib.h>
main()
{
int matriz[3][3];
int i, j;
int maiorDiagonalPrincipal, diagonalSecundaria;
maiorDiagonalPrincipal = scanf("%i", &matriz[0][0]);
diagonalSecundaria = 0;
public class Infoweek {
private static AlertUtils alertUtils = new AlertUtils();
private static Context ctx;
private Infoweek(){}
public static void init(Context ctx) {
Infoweek.ctx = ctx;
}
public static double somar(CharSequence primeiroValor, CharSequence segundoValor) {
if(primeiroValor.toString().isEmpty() || segundoValor.toString().isEmpty()) {
class AlertUtils {
private AlertDialog build(Context ctx, String title, String text){
return new AlertDialog.Builder(ctx)
.setCancelable(true)
.setTitle(title)
.setMessage(text)
.create();
}
public void show(Context ctx, String title, String text) {
AlertDialog dialog = build(ctx, title, text);
@leonardocordeiro
leonardocordeiro / EnviarMensagem.java
Created January 25, 2015 20:04
GCM Server-side
package br.com.caelum.gcm;
import java.io.IOException;
import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.Sender;
public class EnviarMensagem {
private static final String API_KEY = "";
private static final String DEVICE_ID = "";
@leonardocordeiro
leonardocordeiro / settings.xml
Created August 11, 2015 06:59
Configurando o Maven com HTTP Proxy (UEZO)
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
<proxy>
String nome = "Leonardo";
String senha = "' or 1=1 #";
Connection cnn = DriverManager.getConnection("jdbc:mysql://localhost/sql_injection", "root", "");
PreparedStatement statement = cnn.prepareStatement("select * from Usuario where nome = '" + nome + "' and senha='" + senha + "';");
ResultSet resultSet = statement.executeQuery();
while(resultSet.next())
System.out.println(resultSet.getString("nome"));
@leonardocordeiro
leonardocordeiro / Servico.java
Created February 6, 2016 03:53
FJ-57 servico medias
@Path("/mobile")
public void service() throws Exception {
BufferedReader reader = request.getReader();
StringBuilder sb = new StringBuilder();
String json;
while((json = reader.readLine()) != null) {
sb.append(json);
}
@leonardocordeiro
leonardocordeiro / PopulaMovimentacao.java
Last active August 22, 2019 20:22
Classe PopulaMovimentacao do treinamento de JPA do Alura
package br.com.caelum.financas.util;
import java.math.BigDecimal;
import java.util.Calendar;
import javax.persistence.EntityManager;
import br.com.caelum.financas.modelo.Conta;
import br.com.caelum.financas.modelo.Movimentacao;
import br.com.caelum.financas.modelo.TipoMovimentacao;