Skip to content

Instantly share code, notes, and snippets.

View jcemer's full-sized avatar
🐢
.

Jean Carlo Emer jcemer

🐢
.
View GitHub Profile
@jcemer
jcemer / angular-test-helper-usage.ts
Last active April 2, 2018 02:09
Let's make your life better testing Angular like writing jQuery code. It's inspired by https://github.com/airbnb/enzyme.
describe('Component', () => {
let wrapper;
beforeEach(() => {
wrapper = build(Component);
wrapper.set({
data: 'value',
});
});
/* @flow */
import typify from "typify"
class Ok<A> {
value: A
constructor(value: A) {
this.value = value
}
}

This is a proposal for a lightning talk at the Reactive 2016 conference. If you like this, star the Gist.


Thinking metrics on React applications

In regular websites, it is common to send multiple events to track user clicks. Single Page Applications change the way you look at metrics. This is a talk about a simple pattern we created at Globo.com to manage a metrics layer for http://globoplay.globo.com. The talk will cover how to track user flow using Google Analytics and other services. We solved the challenge of tying metrics and components, keeping information across pages and having global data. Also some React, React Router and React Side Effects concepts like context, higher order components, history state will be covered.

var vm = require('vm')
var sandbox = {externalArray: [], externalArryConstructor: Array}
vm.createContext(sandbox)
console.log(vm.runInContext('externalArryConstructor == Array', sandbox))
console.log(vm.runInContext('externalArray.constructor == Array', sandbox))
console.log(sandbox.externalArray.constructor == Array)
console.log(vm.runInContext('externalArray.__proto__ == [].__proto__', sandbox))
@jcemer
jcemer / add.js
Created July 8, 2014 19:09
Browserify sample
module.exports = function (a, b) {
return a + b;
};
@jcemer
jcemer / code.scss
Last active December 26, 2015 09:29
.section-title {
font-size: rem(28px);
color: $blue;
@include inverse-bottom-line(80%);
}
.collaborate-item:last-child {
@include left-line(90%);
padding-left: 10%;
}

.address-map {
@jcemer
jcemer / gist:5400404
Last active December 16, 2015 07:39
Count repeated words.
# it parses "a a a a b b b c c" to {"a"=>4, "b"=>3, "c"=>2}
# FROM
def self.estatisticas_do_texto(texto)
palavras = []
texto.split(' ').each do |word|
w = word.downcase.gsub(/\.|\,|\?|\!|\(|\)|\'/,'')
palavras << w
end
palavras.sort!
@jcemer
jcemer / gist:4324878
Created December 18, 2012 03:59
No country for old men
var x = 2
with ({x:3}) {
console.log(x)
}
@jcemer
jcemer / robot.js
Created December 4, 2012 16:54 — forked from cezarsa/robot.js
Simple Wall Robot
var Robot = function(robot){
robot.turnLeft(robot.angle % 90);
robot.turnGunRight(90);
robot.clone();
this.direction = 1;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(1);
if (robot.parentId) {