Skip to content

Instantly share code, notes, and snippets.

View ivmarkp's full-sized avatar

Vivek Pal ivmarkp

  • New Delhi, India
View GitHub Profile
diff --git a/xapian-applications/omega/Makefile.am b/xapian-applications/omega/Makefile.am
index ae10f2ad6e2b..0393b6fa6c0b 100644
--- a/xapian-applications/omega/Makefile.am
+++ b/xapian-applications/omega/Makefile.am
@@ -181,7 +181,7 @@ libtransform_la_LIBADD = $(PCRE_LIBS)
omega_SOURCES = omega.cc query.cc cgiparam.cc utils.cc configfile.cc date.cc\
cdb_init.cc cdb_find.cc cdb_hash.cc cdb_unpack.cc jsonescape.cc loadfile.cc\
datevalue.cc common/str.cc sample.cc urlencode.cc weight.cc expand.cc\
- csvescape.cc timegm.cc
+ csvescape.cc timegm.cc md5.cc md5wrap.cc
@ivmarkp
ivmarkp / clicklog
Last active June 17, 2017 10:54
Omegascript template to log the clicked document ID along with query ID
$httpheader{Content-Type,text/html; charset=utf-8}<!DOCTYPE html><html lang="en">
<meta http-equiv="refresh" content="0.1;url=$cgi{URL}">
$log{clicks.log, "$cgi{QUERYID}\t""$cgi{DOCID}"}
</html>
@ivmarkp
ivmarkp / clicklog.js
Last active June 13, 2017 23:08
Javascript to be stored as clicklogjs in the templates/inc directory.
<script type="text/javascript"><!--
function clicklog() {
// Redirect to the clicklog template with $id of the clicked document.
// We could do something like:
// window.location.assign("../clicklog")
// to redirect to the clicklog template.
// I'm not sure about how we could pass $query and the clicked doc $id to the template.
return true; // To allow following the href link in the <a> tag i.e. document url.
}
// -->
@ivmarkp
ivmarkp / omega.txt
Last active May 30, 2017 02:18
Setting up Omega CGI
Command: Indexing
sudo /usr/local/bin/omindex -v --db=/var/lib/omega/data/default --url=/ /var/www
Output:
[Entering directory ""]
Indexing "ci_10.htm" as text/html ... already indexed
Indexing "ci_07.htm" as text/html ... already indexed
Indexing "ci_30.htm" as text/html ... already indexed
Indexing "ci_39B.htm" as text/html ... already indexed
Indexing "ci_20.htm" as text/html ... already indexed
Indexing "ci_33.htm" as text/html ... already indexed
@ivmarkp
ivmarkp / autoencoder.hpp
Last active March 27, 2017 10:41
Abstract class for Autoencoders
namespace mlpack {
namespace nn {
class Autoencoder {
public:
Autoencoder(const arma::mat& data,
const size_t inputSize,
const size_t hiddenSize,
NoiseLayerType&& noiseLayer = NoisetLayerType());
checksum@inspiron:~/Documents/xapian/build/xapian-applications/omega$ git diff
diff --git a/xapian-applications/omega/omegatest b/xapian-applications/omega/omegatest
index b8505e2cf040..d6c9d78814e4 100755
--- a/xapian-applications/omega/omegatest
+++ b/xapian-applications/omega/omegatest
@@ -302,6 +302,18 @@ testcase '.~~D' DOCIDORDER=D
testcase '.~~' DOCIDORDER=X # Buggy, but kept for compatibility.
testcase '.~~' DOCIDORDER=x # Buggy, but kept for compatibility.
+# Feature tests for $highlight{}.
@ivmarkp
ivmarkp / omegatest.sh
Last active March 19, 2017 19:51
A testcase for $highlight{} command.
# Tests for $highlight.
printf '$highlight{$cgi{a},$cgi{b},$cgi{c},$cgi{d}}' > "$TEST_TEMPLATE"
testcase 'A list of <b>words</b>' P=text a="words" b="A list of words" c="<b>" d="</b>"
unordered_map<string, int> word_to_occurrence;
// Build map before line 755 in query.cc by calling the method build_word_map.
void build_word_map(const string& list) {
string word;
int count = 0;
for (size_t i = 0; i <= list.length(); ++i)
{
// Initialise the parameters mem, g and g2.
arma::mat mem = arma::ones<arma::mat>(iterate.n_rows, iterate.n_cols);
arma::mat g = arma::zeros<arma::mat>(iterate.n_rows, iterate.n_cols);
arma::mat g2 = arma::zeros<arma::mat>(iterate.n_rows, iterate.n_cols);
// And update the iterate.
arma::mat r = 1 / (mem + 1);
@ivmarkp
ivmarkp / test.cpp
Last active February 23, 2017 18:34
Test whether using arma::max function is faster than using loops.
#include <iostream>
#include <vector>
#include <ctime>
#include <armadillo>
using namespace std;
using namespace arma;
int main() {
mat A = randu<mat>(10000,10000);