Skip to content

Instantly share code, notes, and snippets.

View tupton's full-sized avatar

Thomas Upton tupton

View GitHub Profile
function useTableQuery(queryFn, columnDefs, formatApiData, formatParamsToQueryKey) {
const [queryKey, setQueryKey] = useState('');
const {data, isLoading} = useQuery(queryKey, () => queryFn({ordering: queryKey.sortBy}));
const tableData = useMemo(() => formatApiData(data), [data]);
const columns = useMemo(() => columnDefs, [columnDefs]);
const fetchData = useCallback((params) => {
const paramsToQK = formatParamsToQueryKey(params);

Does markdown work here?

  • And what about here?
  • Possibly.

A fancy | Table

@tupton
tupton / get-up-apple-music-2020-03-23.txt
Created March 25, 2020 17:14
Get Up! Mix 2020-03-23
Cult Leader - Aurum Reclusa
AXIS - With Grace
Nails - Your God
Integrity - Simulacra
Trap Them - Gift and Gift Unsteady
Dead in the Dirt - The Blaring Eye
Loma Prieta - Never Remember
Creeping Death - Bloodlust Contamination
Modern Life Is War - Humble Streets
Ceremony - Back In '84
@tupton
tupton / keybase.md
Created March 15, 2020 11:35
keybase.md

Keybase proof

I hereby claim:

  • I am tupton on github.
  • I am tupton (https://keybase.io/tupton) on keybase.
  • I have a public key ASBctvCZaghnMCnQ9DRzjMkcNiKXw9ck0pL4WO3Np3dbGAo

To claim this, I am signing this object:

@tupton
tupton / useSupportSidebar.js
Created October 21, 2019 19:19
hook that provides a jsx component
const useSupportSidebar = () => {
const classes = useStyles();
const [isSidebarOpen, setSidebarOpen] = useState(false);
const toggleSidebar = () => setSidebarOpen(!isSidebarOpen);
const closeSidebar = () => setSidebarOpen(false);
const drawerStateClass = isSidebarOpen ? classes.drawerOpen : classes.drawerClose;
@tupton
tupton / lastfm-stats-listening-time.py
Last active December 12, 2017 21:28
Example excerpt from jupyter notebook
# get_tracks is an api method to get recent tracks for a user, with paging and caching
# get_track is an api method to get a single track from mbid or artist+name, with caching
import itertools
from operator import itemgetter
def track_to_artist_and_duration(track):
api_track = get_track(track)
return (track.get('artist').get('name'), track.get('name'), api_track.get('duration'))
@tupton
tupton / reporter-app-date-formatter.py
Created March 22, 2014 22:04
Formatter for Reporter App dates
import datetime
import pytz
def format_report_date(date_or_nsdate):
formatted = None
if type(date_or_nsdate) is float:
try:
reference_date = datetime.datetime(2001, 1, 1, 0, 0, 0, 0, pytz.utc).strftime('%s')
formatted = datetime.datetime.fromtimestamp(long(reference_date) + date_or_nsdate)
except e:
javascript:(function(e,t){var n=e.document;setTimeout(function(){function a(e){if(e.data==="destroy_bookmarklet"){var r=n.getElementById(t);if(r){n.body.removeChild(r);r=null}}}var t="DELI_bookmarklet_iframe",r=n.getElementById(t);if(r){return}var i="https://delicious.com/save?",s=n.createElement("iframe");s.id=t;s.src=i+"url="+encodeURIComponent(e.location.href)+"&title="+encodeURIComponent(n.title)+"&note="+encodeURIComponent(""+(e.getSelection?e.getSelection():n.getSelection?n.getSelection():n.selection.createRange().text))+"&v=1.1";s.style.position="fixed";s.style.top="0";s.style.left="0";s.style.height="100%25";s.style.width="100%25";s.style.zIndex="16777270";s.style.border="none";s.style.visibility="hidden";s.onload=function(){this.style.visibility="visible"};n.body.appendChild(s);var o=e.addEventListener?"addEventListener":"attachEvent";var u=o=="attachEvent"?"onmessage":"message";e[o](u,a,false)},1)})(window)
@tupton
tupton / gist:4027889
Created November 6, 2012 22:01
Concise Opscenter Alerts
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DataStax OpsCenter Alerts</title>
<script src="js/dojotoolkit/dojo/dojo.js"></script>
<script>
require([
'dojo/_base/lang',
'dojo/_base/xhr',
@tupton
tupton / gist:3145451
Created July 19, 2012 17:21
FIXME and TODO
<?php
function getObject($id) {
$object = null;
// TODO Do we need to validate username?
$objects = $this->db->retrieveForUsername($this->username);
// FIXME Write `retrieveForIdAndUsername` instead of iterating here
foreach ($objects as $o) {