Skip to content

Instantly share code, notes, and snippets.

View ericwenn's full-sized avatar

Eric Wennerberg ericwenn

View GitHub Profile
const _ = () => (
<Table
columns={[
{ label: "Id", value: "id", size: 2, sortable: false},
{ label: "Name", value: "name", size: 2, sortable: false},
]}
renderRow={(data, gridProps) => (
<Grid {...gridProps[i]}>{data.id}</Grid>
<Grid {...gridProps[i]}>{data.name}</Grid>
)}
interface Cache<T> {
get: (id: string) => T | null;
set: (id: string, item: T) => void;
invalidate: (id: string) => void;
};
interface CacheEntry<T> {
// Unix timestamp Math.floor(new Date() / 1000)
cachedAt: number;
item: T;
@ericwenn
ericwenn / relevant_image.php
Last active August 29, 2015 14:00
Get the most relevant image in WordPress
<?php
/**
* Returns the attachment id for the most relevant image of the post
* @author Eric Wennerberg
* @package Flavour
*/
function get_relevant_image() {
if(has_post_thumbnail()) {
return get_the_featured_image_id();
} else {