Skip to content

Instantly share code, notes, and snippets.

View mcrisc's full-sized avatar

Marcelo Criscuolo mcrisc

View GitHub Profile
/*
The MIT License
Copyright (c) 2011, Marcelo Criscuolo.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@mcrisc
mcrisc / nottodayjimmywales.user.js
Created November 27, 2011 14:05
User script that removes Wikipedia banners
// ==UserScript==
// @name Not today, Jimmy Wales!
// @namespace http://jau.org/userscripts
// @include http://*.wikipedia.org/*
// @include http://*.wikiversity.org/*
// ==/UserScript==
/*
Firefox: runs over GreaseMonkey or Scriptish
@mcrisc
mcrisc / my_pi.py
Created December 20, 2011 15:51
Estimates the value of PI
#coding: utf-8
# Estimates the value of PI
# Based on example described at http://code.google.com/edu/parallel/mapreduce-tutorial.html#Basics
# Author: Marcelo Criscuolo (Jaú), with
# invaluable contributions from Rafael Giusti (Argentino)
import math
from datetime import datetime
RADIUS = 50000 # the bigger the number, more precise is the estimation
@mcrisc
mcrisc / my_parallel_pi.py
Last active September 28, 2015 22:38
Estimates the value of PI (parallel implementation)
#coding: utf-8
# Estimates the value of PI
# Based on example described at http://code.google.com/edu/parallel/mapreduce-tutorial.html#Basics
# Author: Marcelo Criscuolo (Jaú), with
# invaluable contributions from Rafael Giusti (Argentino)
import math
from datetime import datetime
from multiprocessing import Pool, cpu_count
@mcrisc
mcrisc / summarizer.py
Created February 27, 2014 20:35
Centroid-based Text Summarization
#coding: utf-8
"""
Centroid-based Summarization
[Jurafsky & Martin, 2nd ed, ch23, sec23.4.1]
Author: Marcelo Criscuolo (criscuolo[dot]marcelo[at]gmail[dot]com)
Date: 2013-07-19
"""
from __future__ import print_function
@mcrisc
mcrisc / scan.sh
Last active August 29, 2015 14:03
Simple script for scanning pen drives for common security threats from Windows world
#!/bin/bash
if [ $# -lt 1 ]; then
echo "usage: $0 <directory>"
exit 1
fi
TARGET_DIR=$1
echo "Running clamscan..."
#!/bin/bash
if [ -z "$1" ]; then
echo "usage: `basename $0` <source-file> [output-file]"
exit 1;
fi
output=$2
if [ -z "$2" ]; then
output="pygmentized.rtf"
@mcrisc
mcrisc / pseudorbf.py
Created February 26, 2016 13:16
Document clustering from similarity matrix
# coding: utf-8
import logging
import random
import numpy as np
UNKNOWN = -1
NOT_FOUND = -1
MIN_SIMILARITY = 0.90
def mycosine(v1, v2):
"""
Calcular o cosseno do ângulo theta, formado pelos vetores v1 e v2.
"""
raise NotImplementedError
# -- BEGIN: não alterar --
try:
import argparse
def main():
parser = argparse.ArgumentParser(
description='Compute precision at k.')
parser.add_argument(
'-k', help='k, to compute precision@k', type=int, default=1)
parser.add_argument('qrels', help='TREC relevance file (qrels)')
parser.add_argument('topfile', help='TREC results file')