Skip to content

Instantly share code, notes, and snippets.

View rabet's full-sized avatar

rabet

View GitHub Profile
@Shrugsy
Shrugsy / rtkQueryCacheUtils.ts
Last active November 14, 2024 10:31
RTK Query cache utils. Useful abstractions for creating `provides`/`invalidates` cache data tags against endpoints.
import { FetchBaseQueryError } from '@rtk-incubator/rtk-query/dist';
/**
* Default tags used by the cacher helpers
*/
const defaultTags = ["UNAUTHORIZED", "UNKNOWN_ERROR"] as const;
type DefaultTags = typeof defaultTags[number];
function concatErrorCache<T, ID>(
existingCache: CacheList<T, ID>,
@mgreer
mgreer / codeSplitting.js
Last active August 31, 2021 21:29
Code splitting HOC
// @flow
import * as React from 'react';
import {asyncComponent} from 'react-async-component';
export const loaderMaker = (bgColor: string = 'transparent') => () => (
<div style={{position: 'absolute', width: '100%', height: '100%', backgroundColor: bgColor}} />
);
const MAX_RETRIES = 3;
const STARTING_BACKOFF = 500;
@rmosolgo
rmosolgo / Gemfile
Last active March 27, 2023 08:38
GraphQL Ruby Subscriptions
source 'https://rubygems.org'
gem "graphql", github: "rmosolgo/graphql-ruby", branch: "subscriptions"
gem "sinatra"
gem "thin"
@langpavel
langpavel / GraphQLTimestamp.js
Last active July 28, 2023 08:46
GraphQLTimestamp.js
import { Kind } from 'graphql/language';
import { GraphQLScalarType } from 'graphql';
function serializeDate(value) {
if (value instanceof Date) {
return value.getTime();
} else if (typeof value === 'number') {
return Math.trunc(value);
} else if (typeof value === 'string') {
return Date.parse(value);
import React from 'react'
import $ from 'jquery'
import 'jquery-ui/datepicker'
import 'jquery-ui/themes/ui-lightness/jquery-ui.css'
var Datepicker = React.createClass({
getDefaultProps() {
return {
onChange() {}
}
// make a "base" component
const FakeButton = (props) => (
<div
{...props}
style={{
cursor: 'default',
border: '1px solid',
borderRadius: '3px',
...props.style
}}
@staltz
staltz / introrx.md
Last active November 17, 2024 01:08
The introduction to Reactive Programming you've been missing