Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
preparing quantum deep learning projects

Cleuton Sampaio cleuton

💭
preparing quantum deep learning projects
View GitHub Profile
@cleuton
cleuton / JsonDao
Last active Aug 29, 2015
JSON DAO Interface
View JsonDao
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 Aug 29, 2015
JSON DAO Implementation using MongoDB
View DaoMongoDB
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 Aug 29, 2015
JSON DAO Test case
View TestDaoInsert
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 Aug 29, 2015
A Jersey/JSON Webservice running an embedded Jetty Container
View Jersey JSON Webservice with Jetty
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 Mar 11, 2014
web.xml for a Jersey/Jetty Webservice
View gist:9496157
<?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 Mar 11, 2014
Http client test for a Jersey/JSON Web service
View Jersey test
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 Mar 12, 2014
HTML 5 / jQuery client for a Jersey / Jetty enabled web service
View index.html
<!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 Mar 12, 2014
Jersey / JSON Webservice running an enbedded Jetty
View pom.xml
<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>
View lcom4bad
public class One {
int x;
int y;
void a() {
b();
}
int b() {
return this.x;
@cleuton
cleuton / lcom4good
Created Mar 18, 2014
LCOM4 = 1 sample
View lcom4good
public class One {
int x;
int y;
void a() {
b();
}
int b() {
return this.x;