Skip to content

Instantly share code, notes, and snippets.

View joelhooks's full-sized avatar
🍄

Joel Hooks joelhooks

🍄
View GitHub Profile
@joelhooks
joelhooks / progress.sql
Created October 10, 2020 19:18
access the individual user's progress through a list of lists via polymorphic join table
select lesson from (
with
-- root collection is a collection of collections (playlist of playlists) which use a polymorphic join table (tracklists) so we want to snag the ids of the sub-collection.
root_collection_ids as ( select tracklists.tracklistable_id id from playlists inner join tracklists on playlists.id = tracklists.playlist_id where playlists.slug = 'some-playlist-id' and tracklists.tracklistable_type = 'Playlist'),
-- the next layer are video resources (lessons) that are the tracklists of the tracklists
lesson_ids as (select tracklists.tracklistable_id lesson_id from root_collection_ids inner join tracklists on root_collection_ids.id = tracklists.playlist_id where tracklists.tracklistable_type = 'Lesson' )
-- we only care about completions so we can get the slug id for all of the video resources (lessons) the user has completed and sort display on the client accordingly
@joelhooks
joelhooks / machine.js
Last active September 8, 2020 19:45
Generated by XState Viz: https://xstate.js.org/viz
const playerMachine = Machine({
id: 'player',
initial: 'loading',
context: {
retries: 0
},
states: {
loading: {
on: {
@joelhooks
joelhooks / machine.js
Last active May 28, 2020 00:39
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@joelhooks
joelhooks / machine.js
Last active April 24, 2020 08:26
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@joelhooks
joelhooks / machine.js
Last active April 22, 2020 01:11
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@joelhooks
joelhooks / drip_to_convertkit.js
Created January 10, 2019 23:58
This is a little node app that creates individual csv files for each tag in an exported Drip subscriber (people!) csv
const _ = require('lodash')
const fs = require('fs')
const csv = require('csv-parser')
const writer = require('fast-csv')
const csvFilePath = 'PATH_TO.csv'
const filesToBuild = {}
fs.createReadStream(csvFilePath)
### Keybase proof
I hereby claim:
* I am joelhooks on github.
* I am joelhooks (https://keybase.io/joelhooks) on keybase.
* I have a public key whose fingerprint is 251E 1196 F0E2 7B60 686B E7F2 BE4C F2AD E4D6 2AB7
To claim this, I am signing this object:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width"/>
<style type="text/css">
/**
* RESETS
*/
/* Based on The MailChimp Reset INLINE: Yes. */
[
{
"slug": "react-redux-the-single-immutable-state-tree",
"question": "What is the *entire* state of the application represented as?",
"answer": "A single Javascript object."
},
{
"slug": "react-redux-describing-state-changes-with-actions",
"question": "What is an action?",
"answer": "A minimally represented change of the state"
aasm :column => :state do
state :proposed, :initial => true
state :cancelled
state :accepted
state :claimed
state :submitted
state :rejected
state :updated
state :approved
state :published