Skip to content

Instantly share code, notes, and snippets.

View cleuton's full-sized avatar
💭
preparing quantum deep learning projects

Cleuton Sampaio cleuton

💭
preparing quantum deep learning projects
View GitHub Profile
@cleuton
cleuton / JsonDao
Last active August 29, 2015 13:57
JSON DAO Interface
package com.obomprogramador.discoarq.microblog.persistence;
import java.util.List;
import org.json.JSONObject;
public interface JsonDao {
boolean addUser(JSONObject user) throws Exception;
JSONObject findUser(String username, String password) throws Exception;
List<JSONObject> getMessages(JSONObject user) throws Exception;
@cleuton
cleuton / DaoMongoDB
Last active August 29, 2015 13:57
JSON DAO Implementation using MongoDB
package com.obomprogramador.discoarq.microblog.persistence.implementation;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.joda.time.DateTime;
import org.joda.time.Minutes;
import org.json.JSONObject;
@cleuton
cleuton / TestDaoInsert
Last active August 29, 2015 13:57
JSON DAO Test case
package com.obomprogramador.discoarq.microblog.daotests;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@cleuton
cleuton / Jersey JSON Webservice with Jetty
Last active August 29, 2015 13:57
A Jersey/JSON Webservice running an embedded Jetty Container
package com.obomprogramador.discoarq.microblog.main;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@cleuton
cleuton / gist:9496157
Created March 11, 2014 22:06
web.xml for a Jersey/Jetty Webservice
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Example App</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
@cleuton
cleuton / Jersey test
Created March 11, 2014 22:18
Http client test for a Jersey/JSON Web service
package com.obomprogramador.discoarq.microblog.daotests;
import static org.junit.Assert.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@cleuton
cleuton / index.html
Created March 12, 2014 18:08
HTML 5 / jQuery client for a Jersey / Jetty enabled web service
<!DOCTYPE html>
<html>
<head>
<title>Microblog</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
var sessao = null;
var usuario = null;
@cleuton
cleuton / pom.xml
Created March 12, 2014 18:32
Jersey / JSON Webservice running an enbedded Jetty
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.obomprogramador.discoarq</groupId>
<artifactId>microblog</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>microblog</name>
@cleuton
cleuton / lcom4good
Created March 18, 2014 10:32
LCOM4 = 1 sample
public class One {
int x;
int y;
void a() {
b();
}
int b() {
return this.x;
@cleuton
cleuton / lcom4bad
Created March 18, 2014 10:46
LCOM4 Bad
public class One {
int x;
int y;
void a() {
b();
}
int b() {
return this.x;