Skip to content

Instantly share code, notes, and snippets.

View emdagon's full-sized avatar

Emilio Daniel González emdagon

View GitHub Profile

Keybase proof

I hereby claim:

  • I am emdagon on github.
  • I am emdagon (https://keybase.io/emdagon) on keybase.
  • I have a public key ASDv0W5b02D3Ilgcu5-BaFlnZmJ_2UI1toFv8H0NuB_NPAo

To claim this, I am signing this object:

@emdagon
emdagon / IncludeTemplate.coffee
Created May 1, 2015 20:08
Simple Component to include Meteor Templates on React Components
# see https://github.com/reactjs/react-meteor
# and https://github.com/jhartma/meteor-cjsx
@IncludeTemplate = React.createClass
componentDidMount: () ->
componentRoot = React.findDOMNode(@)
parentNode = componentRoot.parentNode
parentNode.removeChild(componentRoot);
Blaze.render @props.template, parentNode
// Create an absolute jQuery selector for a DOM element.
//
// + el - Element to select.
//
// Returns String selector.
function makeSelector(el) {
var tag, index, stack = [];
for (; el.parentNode; el = el.parentNode) {
tag = el.tagName;
@emdagon
emdagon / PuncturedInt-usage.scala
Last active January 3, 2016 04:49
This is a simple approach to create what I call a "Punctured Number", the idea is to assign a lifetime to each addition or subtraction operation over a number, and once that lifetime passed, the changes of those operation are discarded. So the number will always go back its initial value.
import scala.concurrent.duration._
import PuncturedInt
val p = new PuncturedInt(0, 5 seconds)
p += 20 // Mon Jan 13 22:42:15
p -= 3 // Mon Jan 13 22:42:18
p() // Mon Jan 13 22:42:19 -> returns 17
p() // Mon Jan 13 22:42:21 -> returns -3
p += 11 // Mon Jan 13 22:42:22
#!/usr/bin/python
from pprint import pprint
stream = [
["A", "B", "C", "D", "F", "G", "X", "Y", "T"],
["X", "Y", "A", "F", "C", "D", "G", "Z", "P"],
["A", "F", "G", "B", "C", "D", "B", "C", "U"],
["G", "X", "A", "B", "C", "D", "F", "D", "C"],