Skip to content

Instantly share code, notes, and snippets.

View alexsandro-xpt's full-sized avatar

Alexsandro Souza Pereira alexsandro-xpt

View GitHub Profile
@alexsandro-xpt
alexsandro-xpt / gist:2522945
Created April 29, 2012 00:49
Async CTP exemplo 1
public async Task<int> SumPageSizesAsync(IList<Uri> uris) {
int total = 0;
int i = 0;
int n = 0;
foreach (var uri in uris) {
Console.WriteLine("{0} - {1}", ++n, DateTime.Now.ToString("yyyyMMddHHmmssffff"));
Console.WriteLine(string.Format("{0} Found {1} bytes ...", ++i, total));
var wc = new WebClient();
var data = await wc.DownloadDataTaskAsync(uri);
Console.WriteLine("{0} - {1}", n, DateTime.Now.ToString("yyyyMMddHHmmssffff"));
@alexsandro-xpt
alexsandro-xpt / gist:2523359
Created April 29, 2012 02:06
Algoritmo genético
//Algoritmo genético
//Trabalho de Inteligência Artificial
//Unileste - Centro Universitário do Leste de Minas Gerais
//Professor Reinaldo
//Autor: Alexsandro Souza Pereira Twitter @alexsandro_xpt
using System;
using System.Collections.Generic;
using System.Linq;
@alexsandro-xpt
alexsandro-xpt / gist:2603594
Created May 5, 2012 15:59
Comportamento estranho usando AsyncCTP
public async Task<string> DownloadTaskAsync(string url) {
HeadOnly = true;
bool loop;
HttpWebResponse responseAsync;
do {
loop = false;
var webRequest = (HttpWebRequest) GetWebRequest(new Uri(url));
@alexsandro-xpt
alexsandro-xpt / gist:2777148
Created May 23, 2012 19:09
Trabalhando com arquivos usando C++
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <iostream.h>
void main() {
FILE *arqF = fopen("c:\\funcionarios.txt","r");
char nome[40];
int chapa;
@alexsandro-xpt
alexsandro-xpt / gist:2782358
Created May 24, 2012 15:52 — forked from vquaiato/gist:2782117
Map/Reduce no MongoDB

###Collections Salas{_id} Reservas{_id, sala_id, data}

###Preciso contar as reservas de cada sala por uma data:

map = function () {
    emit(this.sala_id, [1]);
}
@alexsandro-xpt
alexsandro-xpt / gist:3015464
Created June 29, 2012 03:18
Algoritmo genético
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AG
{
public class Pais
@alexsandro-xpt
alexsandro-xpt / gist:3015805
Created June 29, 2012 04:41
Algoritmo genético TestCase
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace AG1 {
class Program {
static bool bit;
@alexsandro-xpt
alexsandro-xpt / gist:3058488
Created July 6, 2012 06:50 — forked from millermedeiros/gist:3057782
Links sobre otimização de performance (WPO)
@alexsandro-xpt
alexsandro-xpt / gist:3124417
Created July 16, 2012 19:07
Crawler data modeling
var WebSiteHistory = [{
Id:1038984165156974140 /* Vai repetir muito(pra cada WebSite_Id x History_Id), é hash do Href. */
,WebSite_Id: 542 /* Id do site crawleado */
,History_Id:6 /* Id da data-tempo que foi crawleado */
,Data: new Date()
,Page: [{
Id:3125795879564125365
,Href:"http://www.terra.com.br" /* Vai repetir muito(pra cada WebSite_Id x History_Id). */
@alexsandro-xpt
alexsandro-xpt / gist:3170014
Created July 24, 2012 13:54
Map Reduce, MongoDB
db.runCommand({
mapreduce: "Page",
map : function Map() {
emit(
this._id, // how to group
{"links":this.Links,"has":false} // associated data point (document)
);