Skip to content

Instantly share code, notes, and snippets.

View colltoaction's full-sized avatar

Martin Coll colltoaction

View GitHub Profile
bool _abb_in_order(abb_nodo_t *nodo, bool visitar(const char *, void *, void *), void *extra){
if (!nodo)
return true;
return _abb_in_order(nodo->der, visitar, extra)
&& visitar(nodo->clave, nodo->dato, extra)
&& _abb_in_order(nodo->izq, visitar, extra);
}
void abb_in_order(abb_t *arbol, bool visitar(const char *, void *, void *), void *extra){
_abb_in_order(arbol->raiz, visitar, extra);
@colltoaction
colltoaction / synchronous_counter_design.md
Last active August 29, 2015 14:11
Synchronous counter design

Synchronous counter design

When designing a synchronous counter, you first draw the counter's state diagram.

With that in mind, you can write the transitions table, where:

  • the independent variables are the current flip-flops' outputs Q[0], Q[1], ... Q[n]
  • you provide the desired next state of the flip-flops' outputs Q[0], Q[1], ... Q[n]
  • the dependent variables are the flip-flops' entries FF[0], FF[1], ... FF[n], which depend on the current state, the desired state, and your flip-flop type
  • there may be extra independent variables like a reset entry, or an up/down entry for an up/down counter
@colltoaction
colltoaction / finger1.R
Last active August 29, 2015 14:27
7506 finger exercise 1
train <- read.csv("train.csv")
ss <- subset(train, select=c("Descript"))
which.max(table(ss))
# GRAND THEFT FROM LOCKED AUTO
ss <- subset(train, Category=="DRIVING UNDER THE INFLUENCE", select=c("DayOfWeek"))
which.max(table(ss))
# Saturday
@colltoaction
colltoaction / district-means.ipynb
Created August 28, 2015 04:23
Generating location means by district for kaggle.com/c/sf-crime using pyspark
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@colltoaction
colltoaction / finger2-entrega.ipynb
Created August 29, 2015 01:42
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 / finger4.ipynb
Created September 11, 2015 17:06
Finger Exercise 4 - Compression
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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):
@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 / 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 / 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"