Skip to content

Instantly share code, notes, and snippets.

Wyatt Johnson wyattjoh

Block or report user

Report or block wyattjoh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@wyattjoh
wyattjoh / AutoSave.tsx
Created Sep 3, 2019
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
View AutoSave.tsx
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 Sep 3, 2019
AutoSave when included in a final-form Form, will automatically call the save method if any field value changes after a debounce timeout.
View AutoSave.tsx
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 Sep 26, 2018
Example for listening for the `action.SHOW_SIGNIN_DIALOG` event to trigger a client side redirect to an external auth source.
View example.html
<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'), {
View gist:be2953874eb7eca03b9fbe7fd829d172
### 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 Aug 18, 2017
How to trigger login actions to occur on the parent?
View readme.md

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 Aug 18, 2017
Disable asset creation plugin
View disable_asset_creation.js
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 Jul 5, 2017
This is a simple server side implementation of what avatar support would look like with The Coral Project's Talk application.
View avatar.js
// 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 Apr 10, 2017
Coral Subscriptions Example
View Embed.js
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 = {
View build.sh
# 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
View migrate.js
db.users.find({}).forEach(function(user) {
db.users.update({id: user.id}, {$set: {
username: user.displayName,
lowercaseUsername: user.displayName
}});
});
You can’t perform that action at this time.