Skip to content

Instantly share code, notes, and snippets.

import React, {createContext, FC, ReactNode, useCallback, useMemo, useReducer} from 'react';
import {usePersistentRef} from '@shared/util/hooks';
export const CardListProviderStateContext = createContext(null);
export const CardListProviderActionsContext = createContext(null);
type Card = any;
interface Query {
channelId: number;
import {cardLayoutSchema} from '@shared/components/card/schema';
import Ajv from 'ajv';
describe('schema', () => {
const ajv = new Ajv();
it('should validate', () => {
const photoScheduleLayout = {
blocks: [
{type: 'image', field: 'imageUri'},
{
"$id": "https://coastapp.com/card-layout.json",
"$schema": "http://json-schema.org/draft-07/schema",
"definitions": {
"section": {
"$id": "#section",
"type": "object",
"properties": {
"type": { "type": "string", "enum": ["section"] },
"fields": {
@ruswerner
ruswerner / spec.md
Last active February 1, 2020 00:05
Component Design Challenge

Component Design Challenge

The brief is to implement the following modal UI using React and inline styles

Modal

Requirements

  • You may use create-react-app for quick project setup
  • The center part of the modal is scrollable to accommodate multiple restaurant listings
@ruswerner
ruswerner / convert-me.jsx
Created January 28, 2020 23:25
Convert this React component to be a function component using hooks
import React, {Component, createRef} from 'react';
import PropTypes from 'prop-types';
export default class ConvertMe extends Component {
ref = createRef();
state = {
operator: ''
};
[
{
"trigger": "click",
"action": "share-pinterest",
"targets": null
},
{
"trigger": "click",
"action": "share-twitter",
"targets": null
@ruswerner
ruswerner / KeyboardBehavior.js
Created December 27, 2013 02:10
Javascript Clipboard Paste
if(event.metaKey && event.keyCode == 86 /* V */) {
var txt = $('<textarea></textarea>');
$('body').append(txt);
txt.on('paste',function(e){
console.log(e.originalEvent.clipboardData.getData('text/plain'));
txt.remove();
}).focus();
return;
}
@ruswerner
ruswerner / cluster.js
Created November 19, 2013 22:14
Nodejs Data Processing Cluster
var cluster = require('cluster');
if(cluster.isMaster) {
var numCPUs = require('os').cpus().length;
var data = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
var currentDataPos = 0;
console.log(numCPUs+' CPUs detected');
var statusInterval = setInterval(function(){