Skip to content

Instantly share code, notes, and snippets.

View renanvalentin's full-sized avatar

Renan Valentin renanvalentin

  • São José do Rio Preto
View GitHub Profile
@renanvalentin
renanvalentin / designer.html
Last active August 29, 2015 14:10
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
@renanvalentin
renanvalentin / router.ex
Created September 24, 2016 21:19
Plug unit testing
defmodule LearningElixir.Router do
use Plug.Router
if Mix.env == :dev do
use Plug.Debugger
end
plug :match
plug :dispatch
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
# Define workers and child supervisors to be supervised
# worker(LearningElixir.Worker, [arg1, arg2, arg3]),
Plug.Adapters.Cowboy.child_spec(:http, LearningElixir.Router, [], [port: 4001])
]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
def run do
{:ok, _} = Plug.Adapters.Cowboy.http LearningElixir.Router, []
end
defmodule LearningElixir.Router do
use Plug.Router
plug :match
plug :dispatch
get "/" do
send_resp(conn, 200, "Hello")
end
defmodule LearningElixir do
use Application
# See http://elixir-lang.org/docs/stable/elixir/Application.html
# for more information on OTP Applications
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
# Define workers and child supervisors to be supervised
defmodule LearningElixir.Router.Test do
use ExUnit.Case, async: true
use Plug.Test
alias LearningElixir.Router
@opts Router.init([])
test "returns hello text" do
response = conn(:get, "/")
@renanvalentin
renanvalentin / polyfills.js
Last active June 29, 2017 18:24
Storybook's jsdom setup
var mockWebSocket = require('mock-socket').WebSocket;
/* globals window, document */
const jsdom = require('jsdom').jsdom;
global.document = jsdom('');
global.window = document.defaultView;
Object.keys(document.defaultView).forEach((property) => {
if (typeof global[property] === 'undefined') {
global[property] = document.defaultView[property];
@renanvalentin
renanvalentin / patch.js
Created June 8, 2017 19:33
ReactDOM.findDOMNode monkey patch
const ReactDOM = require('react-dom');
const findDOMNode = ReactDOM.findDOMNode;
ReactDOM.findDOMNode = (component) => {
if (findDOMNode) {
return findDOMNode(...args);
}
if(!component.container) {