This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
class SimpleGraph: | |
def __init__(self): | |
self.edges = {} | |
def neighbors(self, id): | |
return self.edges[id] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Channel = { | |
on(event : string, listener : Function): * | |
}; | |
export type Subscriber = { | |
listener(config : { window : HTMLIFrameElement, domain : string }): Channel | |
}; | |
const subscribe = (channel : Channel) => { | |
let listeners = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ReactDOM = require('react-dom'); | |
const findDOMNode = ReactDOM.findDOMNode; | |
ReactDOM.findDOMNode = (component) => { | |
if (findDOMNode) { | |
return findDOMNode(...args); | |
} | |
if(!component.container) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, "/") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule LearningElixir.Router do | |
use Plug.Router | |
plug :match | |
plug :dispatch | |
def start_link do | |
{:ok, _} = Plug.Adapters.Cowboy.http LearningElixir.Router, [], [port: 4001] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule LearningElixir.Router do | |
use Plug.Router | |
plug :match | |
plug :dispatch | |
get "/" do | |
send_resp(conn, 200, "Hello") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run do | |
{:ok, _} = Plug.Adapters.Cowboy.http LearningElixir.Router, [] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder