Hugo Santos bio photo

Hugo Santos

Twitter Google+ LinkedIn Github

All Posts

2014

Career outside the Matrix

Every year student grads enter the work force. At least they try to. Through job ads they hope to catch a glimpse of ...

2013

Relevant keywords using TF-IDF

TF-IDF is a numerical statistic that tells us how important some word is in a document. It stands for term frequency ...

RTFM extended

As you know RTFM stands for Read the Fucking Manual. Today, I would like to introduce you to RTWFM which stands for R...

Classes in C Programming

Last evening I was playing around with C and came up with an example showing simple OOP concepts.The working behaviou...

Fibonacci ultra fast

It’s never too late to optimize the code. Never too late to realize there’s a better approach.After writing the last ...

Accelerating with memoization

Memoization can be incredible useful for expensive calculations. Just look at the results at the bottom of the post t...

sqrt newton way

I was working through a way to get a square-root function to work in scheme.(define (sqrt2 x) (sqrt-iter 1 x))(defin...

Delta Debugging

Delta Debugging is an automated debugging approach based on systematic testing.Programmers follow this approach when ...

Bitwise and CONSTANT values

Recently I read an article explaining how to use bitwise operations to grant or deny access to something.I liked the ...

Making of a simple debugger

I was introduced to sys.settrace in the Udacity course on debugging. Python docs say:>Set the system’s trace funct...

Preconditions, Postconditions and Invariants

Frequently when debugging software we usually spend lots of time figuring out where exactly is the bug that is creati...

Software Debugging

I started Software debugging class on Udacity.SyllabusUnit 1: How Debuggers workTheory: Scientific method and its app...

Babysitting an army of monkeys

“Babysitting an Army of Monkeys: An analysis of fuzzing 4 products with 5 lines of Python” was the title of a talk by...

Code coverage

Code coverage is a metric used in software testing that describes the percentage of code that’s been tested.Some type...

Software Testing

Today I started Software Testing class on Udacity.In the first unit Prof. John Regehr talked about a specification is...

Class inheritance check with __mro__

Consider the following code:class A(object): passclass B(A): passclass C(B): passclass D(C): passAs you c...

Decorators in Python

Today I’ll turn you into a decorator. Let’s build a house and decorated it.First things first… the house. In my world...

Migration to github pages

$ ruby -rubygems -e 'require "jekyll/migrators/wordpressdotcom"; Jekyll::WordpressDotCom.process("...

2012

Portuguese dictionary

Today I played with beautifulsoup and wrote a script to query a portuguese online dictionary.$ ./porto-dict <word&...

Nokogiri

Today I found Nokogiri.>Nokogiri is an HTML, XML, SAX, and Reader parser. Among Nokogiri’s many features is the ab...

Quicksort

The complexity of this algorithm is O(n log n). This is a divide and conquer algorithm. We take smaller sub-lists and...

New repo

git initgit addgit commitgit pushCode has been pushed to Github.

Merge Sort

The complexity of this algorithm is O(n log n).The list of elements is recursively divided into smaller ones, each ti...

Shell Sort

This algorithm is based on Insertion Sort but instead of starting the comparison between adjacent elements it introdu...

Insertion Sort

The complexity of this algorithm varies from O(n²) and O(n) on the best case.This algorithm assumes that the array is...

Shaker Sort

This algorithm (AKA cocktail sort) has a complexity of O(n²).The procedure is similar to the bubble sort. In fact, th...

Bubble Sort

This sorting algorithm has a complexity of O(n²).The algorithm compares each element in the array with the element in...

Selection Sort

This sort algorithm has a complexity of O(n²).For each element in the array the algorithm tries to find the lowest va...

Hash Table

A hash table is a data structure that can map keys to values (objects). If we want to search for a value associated w...

Binary Search

The binary search is a divide and conquer search algorithm. In each step it reduces the size of the array to search, ...

Session "hijacking"

PHP sessions are managed with a little (BIG) help from the cookies.When a user requests a URL and the webpage makes u...

Queue data structure

You’re at a reception desk. There are four people waiting in front of you and you have to wait for your turn. That’s ...

Stack data structure

Imagine you have to do the dishes and you put one plate on top of the other.The stack data structure works in that wa...