Skip to content

Instantly share code, notes, and snippets.

View kristojorg's full-sized avatar

Kristo Jorgenson kristojorg

View GitHub Profile
@kristojorg
kristojorg / opds2.ts
Last active August 19, 2020 17:43
Data Types for the OPDS 2.0 Spec
export interface Collection {
type: "application/opds+json"; // must comply with this spec
links: Link[];
}
// a feed is a collection since it has metadata, links and sub collections.
export interface Feed extends Collection {
// sub collections of with roles "navigation", "publication", "group"
navigation?: NavigationEntry[];
publications?: PublicationEntry[];
groups?: GroupEntry[];
@kristojorg
kristojorg / styled-specificity-codemod.js
Last active February 9, 2022 12:08
A codemod to add specificity to styled-components generated css. This helped me fix the issue of jss being placed in the head below styled-components
const tagTypes = {
Identifier: node => node,
CallExpression: node => node.callee,
MemberExpression: node => node.object,
};
module.exports = (file, api, options) => {
const j = api.jscodeshift;
const ast = j(file.source);
@kristojorg
kristojorg / Sparkle.js
Created March 3, 2017 16:29
A component to add sparkles to a webpage.
import React from 'react'
import getContext from 'recompose/getContext'
const defaultDensity = 0.00008872; // multiply by height and width of canvas.
const defaultColor = ["#c5392a","#C0C0C0"];
const LIFE_SPAN = 1500;
const SPEED_Y = 2;
const SPEED_X = 1;
const SPEED_MULTIPLIER = 1/10;
@kristojorg
kristojorg / SceneWrapper.js
Last active November 17, 2016 15:42
Example of a SceneWrapper component, which returns false from shouldComponentUpdate when screen is not in view, and provides a new lifecycle hook for when screen is newly in view.
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import scAx from '../utils/tracking';
import { selectors } from '../redux/index';
const SceneWrapper = ComposedComponent => class Wrapper extends React.Component {