Skip to content

Instantly share code, notes, and snippets.

Chart with upward trend

Dan Ott danott

Chart with upward trend
View GitHub Profile
danott / main.rb
Created Jan 28, 2022
A WIP of codifying the Planning Center company calendar
View main.rb
require 'bundler/inline'
gemfile do
source ''
gem 'repeatable', "= 1.0.0"
weekdays = 1), 2),
danott / 99bottles_shameless_green.js
Last active Sep 2, 2021
My time boxed shameless green for Sandi Metz's 99 Bottles of OOP, JS Edition
View 99bottles_shameless_green.js
import { downTo} from './helpers';
export class Bottles {
verse(number) {
return SONG.split('\n\n').map((v) => v.trim() + '\n').reverse()[number];
verses(begin, end) {
return downTo(begin, end).map(n => this.verse(n)).join('\n');
danott / react_helper.rb
Created Oct 5, 2019
A minimal Rails helper for rendering a React component into the DOM
View react_helper.rb
module ReactHelper
def render_react_component(component:, props: {}, dom_id:)
React.createElement(#{sanitize(component)}, #{raw json_escape(props.to_json)}),
danott / pre-commit
Last active Oct 10, 2022
A git hook that automatically formats JavaScript and Ruby code on commit
View pre-commit
# ./.git/hooks/pre-commit
danott / react_controller.js
Last active Mar 2, 2018
Someone will probably want this.
View react_controller.js
import { Controller } from "stimulus"
import ReactDOM from "react-dom"
import React from "react"
<div controller="react"
data-react-props="{ \"name\": \"Daniel\" }"
danott /
Last active Jun 29, 2017
An idea for page-specific sprinkles that automatically setup and teardown. Doubling down on Server Rendered JavaScript...
class Sprinkle
run: =>
document.addEventListener("turbolinks:load", @setup)
setup: =>
console.log "Sprinkle setup"
document.removeEventListener "turbolinks:load", @setup
document.addEventListener "turbolinks:before-cache", @teardown
teardown: =>
View riddle.markdown


Two intelligent, honest students are sitting together at lunch one day when their math teacher hands them each a card. "Your cards each have an integer on them," the teacher tells them. "The product of the two numbers is either 12, 15 or 18. The first to correctly guess the number on the other's card wins."

The first student looks at her card and says, "I don't know what your number is."

The second student looks at her card and says, "I don't know what your number is, either."

The first student then says, "Now I know your number."

danott / princes.rb
Created Mar 18, 2017
TDD'ing a Riddle
View princes.rb
require "minitest/autorun"
def yes
def no
danott / _partial_that_sets_content_for_block.html.erb
Created Dec 21, 2016
An example of the gymnastics to use `content_for` blocks between a view and partial, where the partial is supposed to appear after the `content_for` block
View _partial_that_sets_content_for_block.html.erb
<% content_for :content_set_within_partial do %>
"Hello! I'm setting a content_for block within a partial"
<% end %>
Hello!, I'm actually rendered in the partial
danott / probably_a_bad_idea.jsx
Last active Dec 20, 2016
A rough example of the idea that you can blow-away child state by passing a new key
View probably_a_bad_idea.jsx
class CanResetChildren extends React.Component {
constructor(props) {
this.state = this.initialState
window.setTimeout(this.reset.bind(this), 60000)
render() {
return (