This file contains hidden or 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
| function toTitleCase(str) { | |
| return str.replace(/^\s+|\s$/g, '').replace(/\b([a-z])/g, function (_, txt) { | |
| return txt.toUpperCase(); | |
| }); | |
| }; |
This file contains hidden or 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 React, { Component } from 'react'; | |
| import { Route } from 'react-router-dom'; | |
| export class DispatchWrapper extends Component { | |
| componentDidMount() { | |
| this.props.action(); | |
| } | |
| render() { | |
| let { component: Component, action, ...rest } = this.props; | |
| return <Component {...rest} />; |
This file contains hidden or 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 SSHt do | |
| def connect(opts \\ []) do | |
| host = Keyword.get(opts, :host, "127.0.0.1") | |
| port = Keyword.get(opts, :port, 22) | |
| ssh_config = defaults(opts) | |
| :ssh.connect(String.to_charlist(host), port, ssh_config) | |
| end | |
| defp defaults(opts) do |
This file contains hidden or 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 SSHt do | |
| @ini_window_size 1024 * 1024 | |
| @max_packet_size 32 * 1024 | |
| @direct_tcpip String.to_charlist("direct-tcpip") | |
| def connect(opts \\ []) do | |
| host = Keyword.get(opts, :host, "127.0.0.1") | |
| port = Keyword.get(opts, :port, 22) | |
| ssh_config = defaults(opts) |
This file contains hidden or 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 SSHt.Application do | |
| @moduledoc """ | |
| Application module | |
| """ | |
| use Application | |
| def start(_type, _args) do | |
| children = [ | |
| {DynamicSupervisor, name: SSHt.TunnelSupervisor, strategy: :one_for_one} | |
| ] |
This file contains hidden or 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 SSHt.Tunnel do | |
| def start_link(ref, to) do | |
| DynamicSupervisor.start_child( | |
| SSHt.TunnelSupervisor, | |
| {SSHt.Tunnel.TCPServer, worker_opts(ref, to)} | |
| ) | |
| end | |
| defp worker_opts(ref, {:tcpip, {port, _}} = to), | |
| do: basic_opts(ref, base_name(port), to) |
This file contains hidden or 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 SSHt.Tunnel.TCPHandler do | |
| use GenServer | |
| require Logger | |
| def start_link(ref, socket, transport, opts) do | |
| pid = :proc_lib.spawn_link(__MODULE__, :init, [{ref, socket, transport, opts}]) | |
| {:ok, pid} | |
| end | |
| def init({ref, socket, transport, opts}) do |
This file contains hidden or 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 SSHt.Tunnel do | |
| @type to :: {:tcpip, tuple()} | {:local, String.t} | |
| @spec start_link(pid(), to) :: {:ok, pid()} | {:error, term()} | |
| def start_link(ref, to) do | |
| DynamicSupervisor.start_child( | |
| SSHt.TunnelSupervisor, | |
| worker_spec(worker_opts(ref, to)) | |
| ) | |
| end |
This file contains hidden or 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 SSHt.Tunnel.TCPHandler do | |
| use GenServer | |
| def start_link(ref, socket, transport, opts) do | |
| pid = :proc_lib.spawn_link(__MODULE__, :init, [{ref, socket, transport, opts}]) | |
| {:ok, pid} | |
| end | |
| def init({ref, socket, transport, opts}) do | |
| target = Keyword.get(opts, :target) |
This file contains hidden or 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 obj = { foo: 'foo', bar: 'bar' }; | |
| const key = 'foo'; | |
| const { [key]: _, ...newObj } = obj; |
OlderNewer