This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
** queue-threadsafe.c | |
** | |
** A thread-safe (for 2 threads) implementation of a queue. Based on the | |
** implementation from the book Embedded Systems, by Jonathan W. Valvano, | |
** chapter 3, page 130. | |
*/ | |
#include <stdlib.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This comment WON'T be processed. | |
*/ | |
static VALUE undocumented_method(VALUE self) { | |
return Qnil; | |
} | |
/* | |
* This comment WILL be processed. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use Homebrew and be happy. | |
brew update | |
brew install opencv | |
# Give the correct pathnames. Of course, `2.4.3` is the current version at this time, change it accordingly. | |
gem install ruby-opencv -- --with-opencv-lib=/usr/local/Cellar/opencv/2.4.3/lib \ | |
--with-opencv-include=/usr/local/Cellar/opencv/2.4.3/include/opencv \ | |
--with-opencv-include=/usr/local/Cellar/opencv/2.4.3/include/opencv2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A very simple naive bayes classifier for english text. | |
# | |
# Author: Carlos Agarie <[email protected]> | |
# Some assumptions: | |
# - The stop words, dataset and test data are hardcoded. | |
# - Binary classification (so each phrase has a corresponding boolean value). | |
# - If there's a missing feature, it's ignored. | |
# | |
# Of course this isn't a finished "product". I'm studying classifiers, so this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The F1 score is a measure of how accurate an algorithm is. | |
# | |
# Precision is the probability that a (randomly selected) retrieved document is relevant: | |
# precision = true positives / (true positives + false positives) | |
# | |
# Recall is the probability that a (randomly selected) relevant document is retrieved in a search: | |
# recall = true positives / (true positives + false negatives) | |
def f1_score(precision, recall) | |
(2 * (precision * recall)) / (precision + recall) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Small experiment in which I try to implement the composite pattern without | |
# resorting to two classes. | |
class Composite | |
attr_accessor :action, :subcomposites | |
# Cool thing: if we don't provide a block, it'll be passed nil. So there's no | |
# need to make it a "default parameter" (you can't do it, actually). | |
def initialize(&action) | |
@action = action |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
require 'open-uri' | |
require 'uri' | |
require 'nokogiri' | |
DEFAULT_DIR = "/Users/carlosagarie/torrents" | |
CATEGORY = 1 # Anime. | |
# Regular expressions and constants for extraction. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From: http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-mac-osx | |
hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/iso.iso | |
# Run diskutil list and determine the device node assigned to your flash media (e.g. /dev/disk2). | |
diskutil list | |
# Replace N with the disk number from the last command. | |
diskutil unmountDisk /dev/diskN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a | |
about | |
above | |
across | |
after | |
afterwards | |
again | |
against | |
all | |
almost |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abaixo | |
aca | |
acaso | |
acerca | |
acima | |
acola | |
acula | |
ademais | |
adentro | |
adiante |