Skip to content

Instantly share code, notes, and snippets.

View domchristie's full-sized avatar
☁️

Dom Christie domchristie

☁️
View GitHub Profile
@domchristie
domchristie / index.html
Last active June 27, 2023 10:37
Transitioning a playing Video with Turbo + Turn
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Videos</title>
<script src="script.js" type="module"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>

Svelte Model

A factory for creating models that encapsulate Svelte stores. Stores can be automatically subscribed to, with their values accessible from an attrs object.

Here's a contrived example to demonstrate the API. A Pattern is a model that can record events, and schedule them to replay on repeat. The inner workings don't really matter here, but notice that active, recordable, and duration are referenced on attrs.

import { writable, derived } from 'svelte/store'

const Pattern = Model(function ({ stores, store, attrs, destroy }) {
@domchristie
domchristie / .block
Last active September 23, 2016 12:15 — forked from mbostock/.block
Multi-Foci Force Layout
license: gpl-3.0
console.log(window.frames.ctl00_secframe.contentDocument.querySelector('h1').textContent)
@domchristie
domchristie / gist:6713650
Created September 26, 2013 12:45
Runs database migrations whilst playing the amen break.
# lib/tasks/db.rake
namespace :dnb do
task :migrate do
pid = spawn("afplay #{File.join(Rails.root, 'lib', 'tasks', 'assets', 'amen_break.wav')}")
Rake::Task["db:migrate"].invoke
Process.wait(pid)
end
end
App.LineItemsController = Ember.ArrayController.extend({
groupedContent: (function() {
var lineItems = this.get('content');
if(!lineItems.get('isLoaded')) {
return null;
}
return lineItems.reduce(function(grouped, object, index, content) {
if(content.objectAt(index-1) &&