Skip to content

Instantly share code, notes, and snippets.

View danott's full-sized avatar
📈
Chart with upward trend

Dan Ott danott

📈
Chart with upward trend
View GitHub Profile
@danott
danott / pre-commit
Last active April 26, 2024 06:46
A git hook that automatically formats JavaScript and Ruby code on commit
#!/bin/sh
# ./.git/hooks/pre-commit
.git/hooks/pre-commit-format-javascript
.git/hooks/pre-commit-format-ruby
@danott
danott / create_staging_branch.sh
Last active February 15, 2024 10:18
Create a fresh staging branch from the latest deployed master.
#!/bin/bash
#
# Assumptions:
# - Clean working tree.
# - Tags are used exclusively to tag deploys
git checkout master
git branch -D staging # Delete staging branch locally.
git push origin :staging # Delete staging branch from GitHub.
git checkout -b staging `git describe --abbrev=0 --tags` # create staging from the latest deployed tag.
@danott
danott / feed.html
Created January 18, 2024 16:34
Hypothetical markup for HTML based feeds. Riffing on the ideas shared at https://blog.jim-nielsen.com/2024/rss-in-html/
<!DOCTYPE html>
<!--
This is hypothetical markup for HTML based feeds.
Riffing on the ideas shared at https://blog.jim-nielsen.com/2024/rss-in-html/
-->
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Dan Ott's HTML Feed</title>
<!-- Tell the machines that there's an HTML feed available at /feed.html -->
@danott
danott / html_rendering_test.rb
Created December 21, 2023 23:03
Embracing the grain of the web's <template> and <slot> tags for rendering declarative markup on the server.
class HtmlRenderingTest < Minitest::Test
CRUST = <<~HTML.strip
<!doctype html>
<html lang="en">
<head>
<title><server-side-slot name="title"><%= title %></server-side-slot></title>
<server-side-slot name="head"></server-side-slot>
<% meta.each do |name, content| %>
@danott
danott / json_storage.js
Created April 26, 2011 15:51
Override localStorage and sessionStorage's getter and setter function to allow for objects/arrays to be stored as well.
/* json_storage.js
* @danott
* 26 APR 2011
*
* Building on a thread from Stack Overflow, override localStorage and sessionStorage's
* getter and setter functions to allow for storing objects and arrays.
*
* Original thread:
* http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage
*/
@danott
danott / youversion_abbreviations.js
Last active December 24, 2022 15:11
YouVersion.com URL Abbreviations
/*!
* youversion_abbreviations.js
* JSON of YouVersion.com Bible Book URL Abbreviations.
*/
var books = {
'gen': 'Genesis',
'exo': 'Exodus',
'lev': 'Leviticus',
'num': 'Numbers',
'deu': 'Deuteronomy',
@danott
danott / modernizr-tests.js
Created March 4, 2011 16:55
Custom Modernizr tests that are useful.
/* modernizr-test.js
* Daniel Ott
* 3 March 2011
* Custom Tests using Modernizr's addTest API
*/
/* iOS
* There may be times when we need a quick way to reference whether iOS is in play or not.
* While a primative means, will be helpful for that.
*/
@danott
danott / relative_time.php
Created June 14, 2011 15:56
Twitter style relative time.
<?php
/*
Origin: http://snipplr.com/view/4912/relative-time/
Copied here for my reference
*/
function plural($num) {
if ($num != 1)
return "s";
@danott
danott / main.rb
Created January 28, 2022 21:32
A WIP of codifying the Planning Center company calendar
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'repeatable', "= 1.0.0"
end
weekdays = Repeatable::Expression::Union.new(
Repeatable::Expression::Weekday.new(weekday: 1),
Repeatable::Expression::Weekday.new(weekday: 2),
@danott
danott / entities.css
Created January 31, 2011 22:07
Use CSS's :after pseudo-selector to insert hexadecimal values of html entities into the document. Less markup. More awesome.
/* Daniel Ott
* entities.css
* 31 January 2011
*
* Adding arrows to thinks makes them more clickable. Right?
* Use CSS's :after pseudo-selector to insert hexadecimal values
* of html entities into the document. Less markup. More awesome.
*/
.add-an-arrow:after {