Skip to content

Instantly share code, notes, and snippets.

View zahlenteufel's full-sized avatar

Gastón Bengolea Monzón zahlenteufel

View GitHub Profile
@zahlenteufel
zahlenteufel / input.scss
Created June 17, 2022 16:00
Generated by SassMeister.com.
@mixin use-mobile-bottom-bar($value) {
.bottom-navigation-buttons-container {
display: if($value, block, none);
}
.navigation-buttons-container {
display: if($value, none, block);
}
}
@zahlenteufel
zahlenteufel / safeHtmlCollector.java
Created April 24, 2018 21:31
Java SafeHtml collector
class xxx {
Collector<SafeHtml, SafeHtmlBuilder, SafeHtml> safeHtmlCollector =
Collector.of(
SafeHtmlBuilder::new,
(BiConsumer<SafeHtmlBuilder, SafeHtml>) SafeHtmlBuilder::append,
(builder1, builder2) -> builder1.append(builder2.toSafeHtml()),
SafeHtmlBuilder::toSafeHtml);
}
@zahlenteufel
zahlenteufel / minRectangle.html
Last active July 29, 2016 23:47
Minimum Enclosing Rectangle
<canvas id="myCanvas" width="500" height="500"></canvas>
@zahlenteufel
zahlenteufel / binary_tree_iterators.cpp
Created July 8, 2015 16:20
Binary Tree Iterators
#include <iostream>
#include <cassert>
using namespace std;
struct node {
int value;
node* left;
node* right;
node *parent;
@zahlenteufel
zahlenteufel / iterative_inorder_traversal.cpp
Created July 8, 2015 12:50
Iterative inorder traversal of a Binary Tree in C++11
#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;
struct node {
int value;
node* left;
node* right;
@zahlenteufel
zahlenteufel / LinCod.py
Created June 4, 2015 02:53
Implementation of Fraenkel's "Error-Correcting-Code using Combinatorial Games"
# 1) for m in 0..n compute g_s(z_m) = mex{g(Z_i_1) xor ... xor g(z_i_j) : 0 <= i_1 < .. < i_j < m, j <=s}
import itertools
import operator
n = 8
s = 3 # s = d - 2
def pack(idxs, n):
return [int(i in idxs) for i in xrange(n)]
@zahlenteufel
zahlenteufel / kwaymerge.cpp
Created June 10, 2014 23:14
K-Way Merge using C++11
template <typename T>
using minheap = priority_queue<T, vector<T>, greater>;
vector<int> kwaymerge(vector<vector<int>>& vs) {
int k = vs.size();
vector<int> readcount(k, 0);
vector<int> res;
vector<pair<int, int>> vec;
for (int i = 0; i < k; i++) {
if (vs[i].size() > 0){
@zahlenteufel
zahlenteufel / parzenWindow.m
Last active August 29, 2015 14:00
Experimenting with Parzen Window in MATLAB for Density Estimation
% Generate the points
clf
subplot(2,1,1);
axis equal
mu1 = [5 4]';
sigma1 = [2 -0.8; -0.8 1];
mu2 = [0 1]';
sigma2 = [1 -0.06;-0.06 0.5];
chol(sigma1);
chol(sigma2); % verifica definida positiva
@zahlenteufel
zahlenteufel / earley.md
Created April 9, 2014 07:38
Earley Algorithm for Non-Deterministic CFG Parsing in Python

#Earley Algorithm for Non-Deterministic CFG Parsing in Python

$ python earley.py "3+2*1+4"

Abstract Syntax Tree for 3+2*1+4

in case it can parse the input, it outputs the Abstract Syntax Tree:

\Tree [.G [.S [.S [.S [.M [.T [.3 ]]]] [.+ ] [.M [.M [.T [.2 ]]] [.* ] [.T [.1 ]]]] [.+ ] [.M [.T [.4 ]]]] [.$ ]]

@zahlenteufel
zahlenteufel / Transitive Reduction.md
Last active August 29, 2015 13:57
Transitive Reduction of a Graph

#Transitive Reduction

Given a DAG (directed acyclic graph), it computes the minimal subgraph that has the same transitive closure. This is the most comfortable way of visualizing for example a partial order (with is transitive).

Uses Graphviz to visualize the results:

Sample