Skip to content

Instantly share code, notes, and snippets.

View drejohnson's full-sized avatar

DeAndre Johnson drejohnson

View GitHub Profile
/* Using jaredly/let-anything */
module Await = {
let let_ = (promise, continuation) =>
promise
|> Js.Promise.then_(value => continuation(value) |> Js.Promise.resolve);
};
let fetchAsync = {
let%Await response = Fetch.fetch("https://swapi.co/api/films/1/");
@drejohnson
drejohnson / algovpn-aws-lightsail.md
Last active July 22, 2024 15:52
Installing Algo Vpn to Amazon Lightsail

Installing Algo Vpn to Amazon Lightsail

  • Create a key pair (see: here if you need help with this step)
  • Log into Lightsail and upload your newly created SSH key to the region in which you plan to deploy your VPN server
  • Create a new $3.50/mo Ubuntu 16.04 LTS Lightsail instance in your desired location
  • Create and attach a static IP address to your new instance
  • Log into the newly created instance and run: do-release-upgrade - this will update the 16.04 instance to 18.04
  • Follow the directions in README.md to deploy the Algo server, selecting "Install Algo to existing Ubuntu 18.04 server" when prompted and using the user "ubuntu" when asked
  • Once Algo finishes installing, log into Lightsail and open UDP ports 500, 4500 and 51820.
@drejohnson
drejohnson / Index.re
Last active June 30, 2020 21:03
basic reasonml binding for lit-html. WIP
/* Works but props not added to values array */
let sayHello = name =>
LitHtml.html(
{j|
<h1>Hello $(name) </h1>
<p>Goodbye</p>
<div>
<span>This is nested</span>
</div>
|j},
@drejohnson
drejohnson / ResizeObserver.d.ts
Created July 5, 2018 18:51 — forked from strothj/LICENSE
ResizeObserver TypeScript definition
interface Window {
ResizeObserver: ResizeObserver;
}
/**
* The ResizeObserver interface is used to observe changes to Element's content
* rect.
*
* It is modeled after MutationObserver and IntersectionObserver.
*/
@drejohnson
drejohnson / Main.elm
Created July 2, 2018 05:52 — forked from pablen/Main.elm
DOM mutation observer helper that will run a hook when a DOM node matching a selector is mounted or unmounted. This pattern is particularly useful for working with external JS libraries in your Elm apps, using minimal amount of code. The helper leverages the MutationObserver API (https://developer.mozilla.org/es/docs/Web/API/MutationObserver).
-- Somewhere in you Elm app you can add editor by adding an empty node with the correct attributes.
-- The JS library will be initialized and destroyed automatically!
view : Model -> Html Msg
view model =
div []
[ div
[ attribute "data-ace" ""
, attribute "data-ace-theme" "monokai"
, attribute "data-ace-mode" "javascript"
@drejohnson
drejohnson / observer.js
Created July 1, 2018 11:06 — forked from ryanve/observer.js
Mutation observer example listening to any attribute changes
!function() {
var emitter = {
emit: console.dir.bind(console)
}
function emit(mutation) {
var target = mutation.target
var name = mutation.attributeName
var value = target.getAttribute(name)
@drejohnson
drejohnson / fp-lenses.js
Created May 24, 2018 04:45 — forked from branneman/fp-lenses.js
JavaScript: Lenses (Functional Programming)
// FP Lenses
const lens = get => set => ({ get, set });
const view = lens => obj => lens.get(obj);
const set = lens => val => obj => lens.set(val)(obj);
const over = lens => fn => obj => set(lens)(fn(view(lens)(obj)))(obj);
const lensProp = key => lens(prop(key))(assoc(key));
@drejohnson
drejohnson / AWSAppSyncClient.re
Created May 17, 2018 22:17
Reason bindings for AWS AppSync
[@bs.module "aws-appsync"] [@bs.new]
external makeAWSAppSyncClient :
{
.
"url": Js.Nullable.t(string),
"region": Js.Nullable.t(string),
"auth":
Js.Nullable.t(
{
.
type hoc = ReasonReact.reactClass => ReasonReact.reactClass;
[@bs.module "react-apollo"] external graphql : GraphQLTag.definitions => hoc = "graphql";
module type Query = {type data; let query: GraphQLTag.definitions;};
module CreateWrapper = (Query: Query) => {
type props = {. "data": Query.data};
let wrapComponent = (~component, ~make) => {
let jsComponent =
type selection = {
.
"alias": string,
"arguments": Js.Array.t(string),
"directives": Js.Array.t(string),
"kind": string,
"name": {
.
"kind": string,
"value": string