Skip to content

Instantly share code, notes, and snippets.

View heukirne's full-sized avatar
💭
Building a non-profit startup: NoHarm.Ai

Henrique Dias heukirne

💭
Building a non-profit startup: NoHarm.Ai
View GitHub Profile
@heukirne
heukirne / experiments_solr.php
Created May 3, 2013 02:19
Course of Information Retrieval
<?php
$topicoStr = file_get_contents("Topicos.txt");
preg_match_all("/title\>([^\<]+)</", $topicoStr, $topicos);
$contRow = 0;
foreach ($topicos[1] as $topic) {
if (strlen(trim($topic))>0) {
$contRow++; $contDoc=0;
wget http://henrique.gemeos.org/download/trec_eval.8.1.tar.gz
wget http://henrique.gemeos.org/download/qrels.zip
unzip qrels.zip
tar -xvf trec_eval.8.1.tar.gz
cd trec_eval.8.1
make
cp trec_eval ../
./trec_eval -c -q qrels.txt result_henrique_manuela_SOLR.txt
./import_logs.py --url=localhost/piwik 20120827_access.log --idsite=1 --force-lowercase-path --log-format-regex="(?P<ip>\S+) \S+ \S+ \[(?P<date>.*?) (?P<timezone>.*?)\] \"\S+ (?P<path>.*?) \S+\" \"\S+ (?P<user_agent>.*?) \S+\" \"\S+ .* \S+\" (?P<status>\S+) (?P<length>\S+) (?P<generation_time_micro>\S+)"
@heukirne
heukirne / iCarros.php
Created July 30, 2013 12:51
Crawler iCarros.com.br
<?php
$link = mysql_connect("mysql07.host.org", "user", "pwd")
or die("Nao foi possivel conectar");
mysql_select_db("gemeos16",$link) or die("Nao foi possivel selecionar o banco de dados");
mysql_query("set wait_timeout = 7200");
$addr = "http://www.icarros.com.br/volkswagen/gol/ficha-tecnica?versao=";
for($i=15000;$i<17000;$i++){
@heukirne
heukirne / gist:7353359
Created November 7, 2013 11:48
Map/Reduce no Mongo para coleção de Posts
map = function() {
this.textContent.split(' ').forEach(
function(word){ emit(word,1); }
);
};
reduce = function(key, values) {
var count = 0;
values.forEach(
@heukirne
heukirne / mongodb-blog.php
Last active December 27, 2015 18:29
MongoDB PHP Blog Example
<?php include('_header.php'); ?>
<?php /* ### Connection ### */
$m = new Mongo("mongodb://guest:guest@host:10047/blogdb");
$db = $m->selectDB("blogdb");
$posts = $db->selectCollection('posts');
?>
<?php /* ### Query ### */
$query = array("title" => "Spoilers Monster High");
@heukirne
heukirne / QueryBuilder.php
Created April 24, 2014 19:24
Query Builder for Yii 2.0 and SQL Server 2005, 2008 (without Limt/Offset support)
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\db\mssql;
use yii\base\InvalidParamException;
@heukirne
heukirne / aggregationI3.js
Last active August 29, 2015 14:03
Cálculo do I3
//Speed up MongoDB Map Reduce, http://edgystuff.tumblr.com/post/54709368492
//MongoDB as a pure in-memory, http://edgystuff.tumblr.com/post/49304254688
db.notas.ensureIndex({c:1});
//db.notas.ensureIndex({p:-1}); //6786ms
db.notas.ensureIndex({a:1});
db.alunos.find().forEach(function(a){ db.notas.update({c:a._id,p:{$gte:a.p}},{$set:{v1:1}},{multi:true}) });
db.grade.find().forEach(function(g){ db.notas.update({a:g.ca},{$set:{v2:1}},{multi:true}) });
@heukirne
heukirne / mapreduceI2.js
Created July 7, 2014 18:08
Cálculo do I2
db.i2.aggregate(
{ $sort: { _id : 1} },
{ $group: { _id: "$c" ,
i : { $first : "$i" },
m : { $first : "$m" },
r : { $first : "$r" },
j : { $first : "$j" },
} },
{ $out: 'i2_group' }
);
@heukirne
heukirne / project.json
Created August 6, 2014 17:59
sharelatex project structure
# db.projects.findOne();
{
"__v" : 0,
"_id" : ObjectId("53e10cd275dd421727dfc823"),
"collaberator_refs" : [ ],
"compiler" : "pdflatex",
"deletedByExternalDataSource" : false,
"deletedDocs" : [ ],
"description" : "",
"lastUpdated" : ISODate("2014-08-06T17:53:46.578Z"),