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 / histogram.go
Created Nov 26, 2019
Histogram using Golang
View histogram.go
// Cleuton Sampaio
package main
import (
"fmt"
"math"
"math/rand"
"github.com/emirpasic/gods/utils"
"gonum.org/v1/plot"
@cleuton
cleuton / StreamDemo2.java
Created Nov 12, 2019
New stream API samples
View StreamDemo2.java
package com.obomprogramador.stream;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class StreamDemo2 {
static class Order {
@cleuton
cleuton / StreamDemo.java
Created Sep 23, 2019
Java Stream API demo
View StreamDemo.java
package com.obomprogramador.stream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class StreamDemo {
View promise.sample
/*
* GET home page.
*/
var Promise = require('promise');
var Request = require('request');
exports.index = function(req, res){
var aprovada = function(httpresponse) {
@cleuton
cleuton / async.waterfall.sample
Created May 21, 2014
Async waterfall sample
View 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 {
@cleuton
cleuton / async route
Created May 9, 2014
Demo async route
View 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' });
View async app js
/*
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
View indexjquery
/*
* 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 / nonblocker.js
Last active Jan 24, 2018
Non blocker cpu intensive node script
View nonblocker.js
// nonblocker.js
var restify = require('restify');
var fs = require('fs');
var Worker = require('webworker-threads').Worker;
var server = restify.createServer();
// Home page:
@cleuton
cleuton / blockerbal.js
Created Apr 8, 2014
This is another version of a bad implementation
View blockerbal.js
// 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');