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 / promise_accessors_with_blocking.coffee
Last active December 27, 2015 04:29
For control flow, we have to absolutely know that a promise is resolved. This is a small pattern I've used in isolation that I would like nitpicked.
class BananaStand extends Batman.Object
@accessor 'hasMoney', promise: (deliver) ->
new Batman.Request
url: "/banana_stand/has_money.json" # true, false
success: (json) ->
deliver(null, json)
return undefined
onResolved: (path, callback) ->
if @get(path) == undefined
@danott
danott / read_only_accessor.js.coffee
Created October 28, 2013 22:24
I want to yell at my future self to not manually set read-only properties. Would anyone else benefit from me implementing some kind of read only accessor in Batman.Object?
# Idea
class Whatever extends Batman.Object
@readOnlyAccessor 'computedValue', ->
@get('otherValue') + 2
# Equivalent
class Whatever extends Batman.Object
@accessor 'computedValue',
get: ->
@get('otherValue') + 2
@danott
danott / git-gretchen-wieners
Last active April 27, 2021 15:04
Keep trying to make fetch happen.
#!/bin/sh
#
# Keep trying to make fetch happen
echo "CTRL+C to quit trying to make fetch happen"
while true; do
git fetch
sleep 60
done
@danott
danott / MY_inflector_helper.php
Created September 3, 2013 23:50
Old CodeIgniter libraries.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Additional custom CodeIgniter Inflector Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author Daniel Ott
* @link http://danott.us
@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 / server.rb
Created July 8, 2013 17:02
Create a simple HTTP server in Ruby. Great for serving static files.
# https://twitter.com/n0kada/status/351556831958667264
ruby -run -e httpd . -p5000
.highlight {
background-color: #efefef;
padding: 7px 7px 7px 10px;
border: 1px solid #ddd;
-moz-box-shadow: 3px 3px rgba(0,0,0,0.1);
-webkit-box-shadow: 3px 3px rgba(0,0,0,0.1);
box-shadow: 3px 3px rgba(0,0,0,0.1);
margin: 20px 0 20px 0;
overflow: hidden;
@danott
danott / 2_timothy.md
Created April 4, 2013 18:27
Synthetic Summary of 2 Timothy

Chapter 1

Verses 1-2

God has given Paul a position, Paul uses that position to share grace, mercy, and peace on God's behalf.

Verses 3-7

Remembering how we've seen God at work in peoples' lives gives us a desire to see his work grow even greater in their lives.

@danott
danott / firefox_bug.js
Last active December 15, 2015 13:28
Came across this obscure Firefox bug while building marshill.com/easter.
/* In Firefox, all assertions pass except -8 and -9. Wat? Works fine in other browsers encountered */
function assert_equal(a, b) {
if (a == b)
console.log("TRUE")
else
console.log("FALSE")
}
assert_equal(parseInt("-01"), -1);
@danott
danott / idea_controller.rb
Last active December 14, 2015 06:29
An idea on writing readable controller code.
# ActionController#action arguments as documentation.
#
# I've been writing controller#action method definitions with inline arguments
# on a recent project. I started taking this approach to provide an at-a-glance
# "documentation" on what inputs an action is expecting to interact with in
# the course of it's execution.
class IdeaController < ActionController::Base
def take_action(email = params[:email], password = params[:password])
# Take some action with email and password