Skip to content

Instantly share code, notes, and snippets.

View colltoaction's full-sized avatar

Martin Coll colltoaction

View GitHub Profile
@colltoaction
colltoaction / inplace-acortar.c
Last active August 2, 2017 17:35
Archivos de ejemplo de edición in-place en C
/*
* Ejercicio [5] final 12/12/06
* Escribir un algoritmo ANSI C que, sin crear archivos intermedios
* altere el archivo a.txt reemplazando la secuencia '//' por '*'
* Excepto si se encuentra entre parentesis
*/
/*
* Compilar con gcc -ansi -std=gnu99 -o prueba inplace-acortar.c
*/
@colltoaction
colltoaction / gtkmm_ovalo.cpp
Created July 5, 2016 04:18
Óvalo que ocupa toda la ventana usando gtkmm
/*
Implemente una rutina (en Windows o Linux) que dibuje un óvalo que ocupe toda la ventana.
*/
#include <gtkmm/drawingarea.h>
#include <gtkmm/application.h>
#include <gtkmm/window.h>
#include <cmath>
class Ovalo : public Gtk::DrawingArea {
@colltoaction
colltoaction / DirectoryException.cpp
Created December 14, 2015 23:26
A simple C++ class that reads files in a directory, and also works as an example of RAII.
#include "DirectoryException.h"
DirectoryException::DirectoryException(const std::string& what_arg)
: std::logic_error(what_arg) {
}
@colltoaction
colltoaction / link-analysis.md
Created December 7, 2015 23:04
Ejercicio de análisis de links basado en el paper http://www9.org/w9cdrom/160/160.html
@colltoaction
colltoaction / pagerank-ex.py
Created December 6, 2015 22:46
PageRank exercise in Python
#!/usr/bin/env python3
"""
1. Calcular el PageRank tematico para el siguiente grafo.
. (2) <---> (1) ----> (3) <---> (4)
Asumir que los nodos que representan el tema de interes son el 1 y el 2 y que el peso del nodo 1 es el doble del tema 2. Usar b=0.7. Y luego identificar la opcion correcta entre las siguientes:
a) TSPR(1) = .2455
b) TSPR(4) = .6680
c) TSPR(1) = .3576
@colltoaction
colltoaction / armbears.svg
Created November 24, 2015 04:50
I support the right to arm bears
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@colltoaction
colltoaction / docker-machine-env.sh
Created November 4, 2015 14:52
docker bug report
tinchou@martin-w81 MINGW64 ~
$ docker-machine -D env --shell cmd default
executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe showvminfo default --machinereadable
STDOUT: name="default"
groups="/"
ostype="Linux 2.6 / 3.x / 4.x (64-bit)"
UUID="212c7825-85fe-4faf-a454-9af114c61af1"
CfgFile="<user path>\\.docker\\machine\\machines\\default\\default\\default.vbox"
SnapFldr="<user path>\\.docker\\machine\\machines\\default\\default\\Snapshots"
LogFldr="<user path>\\.docker\\machine\\machines\\default\\default\\Logs"
@colltoaction
colltoaction / finger2.ipynb
Created October 13, 2015 16:59
Finger Exercise 2
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@colltoaction
colltoaction / lzw.py
Last active October 6, 2015 03:30
Naïve LZW implementation for a school assignment using Python.
class LZW:
def __init__(self):
self.ctx = ""
self.table = [ chr(i) for i in range(256) ]
self.empty_index = 256
self.last_index = None
self._model = []
def encode(self, c):
"""Receives a character to encode. Updates the table."""
@colltoaction
colltoaction / adaptive_arithmetic_coder.py
Last active October 6, 2015 00:53
Adaptive Arithmetic Coder written in Python.
class AdaptiveArithmeticCoder:
FREQ_INIT = 1
def __init__(self, character_space):
self.character_space = character_space
self.count = len(character_space)
self.freqs = [ AdaptiveArithmeticCoder.FREQ_INIT ] * self.count
self.intervals = [ None ] * self.count
self.update_intervals((0, 1))
def update_intervals(self, interval):