Skip to content

Instantly share code, notes, and snippets.

View wyattjoh's full-sized avatar
🏳️‍🌈

Wyatt Johnson wyattjoh

🏳️‍🌈
View GitHub Profile
@wyattjoh
wyattjoh / main.go
Last active December 8, 2022 15:36
package main
import (
"encoding/json"
"flag"
"log"
"net/http"
"os"
)
@wyattjoh
wyattjoh / AutoSave.tsx
Created September 3, 2019 21:08
AutoSave when included in a final-form Form, will automatically call the save method if any field value changes after a debounce timeout. AutoSave is based on the example from: https://codesandbox.io/s/5w4yrpyo7k
import diff from "object-diff";
import React, { useCallback, useEffect, useState } from "react";
import { FormSpy } from "react-final-form";
import { Omit } from "coral-framework/types";
interface Props<T> {
onSave: (values: T) => Promise<void>;
values: T;
debounce: number;
@wyattjoh
wyattjoh / AutoSave.tsx
Created September 3, 2019 21:08
AutoSave when included in a final-form Form, will automatically call the save method if any field value changes after a debounce timeout.
import diff from "object-diff";
import React, { useCallback, useEffect, useState } from "react";
import { FormSpy } from "react-final-form";
import { Omit } from "coral-framework/types";
interface Props<T> {
onSave: (values: T) => Promise<void>;
values: T;
debounce: number;
@wyattjoh
wyattjoh / example.html
Created September 26, 2018 19:04
Example for listening for the `action.SHOW_SIGNIN_DIALOG` event to trigger a client side redirect to an external auth source.
<div id='coralStreamEmbed'></div>
<script src="https://url.for.talk.com/static/embed.js"></script>
<script>
function attachToEvents(events) {
events.on('action.SHOW_SIGNIN_DIALOG', function() {
window.href = "https://url.for.logging.user.in.com/";
});
}
Coral.Talk.render(document.getElementById('coralStreamEmbed'), {
### Keybase proof
I hereby claim:
* I am wyattjoh on github.
* I am wyattjoh (https://keybase.io/wyattjoh) on keybase.
* I have a public key whose fingerprint is D3AD 7A33 9CDC C59F 6F14 C229 F92B EA75 AA55 29D8
To claim this, I am signing this object:
@wyattjoh
wyattjoh / readme.md
Created August 18, 2017 15:42
How to trigger login actions to occur on the parent?

How to trigger login actions to occur on the parent?

  1. Disable the talk-plugin-auth plugin.
  2. Listen for the action.SHOW_SIGNIN_DIALOG event and trigger your signin behaviour, potentially showing a new ui via another plugin in Talk or triggering a redirect on the parent page.
  3. When the page returns (and the login is done) call embed.login() optionally with a token as embed.login(token).
@wyattjoh
wyattjoh / disable_asset_creation.js
Created August 18, 2017 15:29
Disable asset creation plugin
module.exports = {
resolvers: {
RootQuery: {
asset: async (obj, {id}, {loaders: {Assets}}) => {
if (!id) {
return null;
}
return Assets.getByID.load(id);
}
@wyattjoh
wyattjoh / avatar.js
Last active July 5, 2017 15:22
This is a simple server side implementation of what avatar support would look like with The Coral Project's Talk application.
// We need the UserModel because we need to update the user.
const UserModel = require('models/user');
// Get some middleware to use with the webhook.
const auth = require('middleware/authentication');
const authz = require('middleware/authorization');
// Load some config from the environment. This could be changed to a settings
// option later if you want to go that route.
const DEFAULT_AVATAR = process.env.DEFAULT_AVATAR;
@wyattjoh
wyattjoh / Embed.js
Last active April 10, 2017 20:38
Coral Subscriptions Example
import React from 'react';
import {graphql} from 'react-apollo';
import gql from 'graphql-tag';
import PubDate from 'coral-plugin-pubdate/PubDate';
class Embed extends React.Component {
static propTypes = {
# setup the environments
export GOPATH=/tmp/go
mkdir -p "$GOPATH/src/github.com/coralproject"
ln -sf "$PWD" "$GOPATH/src/github.com/coralproject/shelf"
# build the binaries
CURRENT_DATE=$(date +%Y-%m-%d)
LDFLAGS="-X main.GitVersion=$BUILD_NUMBER -X main.GitRevision=$GIT_COMMIT -X main.BuildDate=$CURRENT_DATE"
for APP in askd corald sponged xeniad