Skip to content

Instantly share code, notes, and snippets.

View Johnius's full-sized avatar

John Luke Johnius

  • AppDynamics
  • San Francisco Bay Area
  • 00:08 (UTC -07:00)
View GitHub Profile
@davidrleonard
davidrleonard / from-now.js
Last active February 18, 2024 11:23
moment.fromNow() implemented in vanilla JavaScript as a simple, standalone function. Runs in the browser. No dependencies required.
/**
* Implements all the behaviors of moment.fromNow(). Pass a
* valid JavaScript Date object and the method will return the
* time that has passed since that date in a human-readable
* format. Passes the moment test suite for `fromNow()`.
* See: https://momentjs.com/docs/#/displaying/fromnow/
*
* @example
*
* var pastDate = new Date('2017-10-01T02:30');
@mjtamlyn
mjtamlyn / cursor.py
Last active December 2, 2021 08:42
Graphene pagination
import functools
from django.db.models import Prefetch, QuerySet
import attr
import graphene
from cursor_pagination import CursorPaginator
from graphene.utils.str_converters import to_snake_case
from graphql_relay import connection_from_list