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 / microblog
Created March 20, 2014 11:35
A RESTful / JSON Webservice made with Node.js, and using a Java MongoDB DAO
// (c) http://www.obomprogramador.com
// REST / JSON WS implementation with Node.js calling Java
var restify = require('restify')
var server = restify.createServer()
var fs = require('fs')
var java = require('java')
java.classpath.push("lib/joda-time-2.3.jar")
java.classpath.push("lib/mongo-java-driver-2.11.4.jar")
@cleuton
cleuton / TokenController
Last active August 29, 2015 13:57
A sails.js controller invoking a java class' method
/**
* TokenController
*
* @module :: Controller
* @description :: A set of functions called `actions`.
*
* Actions contain code telling Sails how to respond to a certain type of request.
* (i.e. do stuff, then send some JSON, show an HTML page, or redirect to another URL)
*
* You can configure the blueprint URLs which trigger these actions (`config/controllers.js`)
@cleuton
cleuton / ajaxIe
Created March 24, 2014 13:12
Old Ajax MS IE Sample
<html>
<head>
<title>*** Ajax básico ***</title>
<script>
function iniciaRequest(url) {
// Teste do Browser
if(window.XMLHttpRequest) {
// Não é MS Internet Explorer
@cleuton
cleuton / TestNormalCDC
Created March 26, 2014 17:02
Swing application FEST testcase
package com.obomprogramador.tutoriais.testes.emprestimos;
import static org.fest.assertions.Assertions.assertThat;
import javax.swing.JFormattedTextField;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.TitledBorder;
import org.fest.swing.core.GenericTypeMatcher;
@cleuton
cleuton / blocker.js
Created April 8, 2014 12:05
A Node.js bad example: Blocking server
// blocker.js
/*
This code is a bad example! It will
block the server. It is for demonstration
only.
*/
var restify = require('restify');
var fs = require('fs');
@cleuton
cleuton / blockerbal.js
Created April 8, 2014 15:55
This is another version of a bad implementation
// blockerbal.js
/*
This code is a bad example! It will
block the server. It is for demonstration
only.
Arguments: port number
*/
var restify = require('restify');
@cleuton
cleuton / indexjquery
Created May 9, 2014 21:09
Demo jQuery
/*
* Script de eventos da página index.html
*/
var chave = null;
var calculando = false;
var original = '';
$(document).ready(function(){
$("#btn").click(function(){
if (!calculando) {
@cleuton
cleuton / async app js
Created May 9, 2014 21:13
Demo async app
/*
Copyright 2014 Cleuton Sampaio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@cleuton
cleuton / async route
Created May 9, 2014 21:15
Demo async route
/*
* Página default:
*/
var Worker = require('webworker-threads').Worker;
var redis = require("redis");
var uuid = require('node-uuid');
exports.index = function(req, res){
res.render('index', { title: 'Operação assíncrona', botao: 'Iniciar' });
@cleuton
cleuton / async.waterfall.sample
Created May 21, 2014 12:33
Async waterfall sample
async.waterfall([
function(callback){
// ***** Task 1: Apaga o banco de dados
db.once('open', function () {
db.db.dropDatabase(function(err) {
if(err != null) {
console.log('Erro ao apagar o banco: ' + err);
}
else {