Skip to content

Instantly share code, notes, and snippets.

View danielgtaylor's full-sized avatar

Daniel G. Taylor danielgtaylor

  • iStreamPlanet
  • Seattle, WA
View GitHub Profile
@danielgtaylor
danielgtaylor / main.go
Created December 14, 2023 05:52
Huma v2 manual doc
package main
import (
"encoding/json"
"fmt"
"net/http"
"reflect"
"github.com/danielgtaylor/huma/v2"
"github.com/go-chi/chi/v5"
@danielgtaylor
danielgtaylor / example.apib
Created November 5, 2015 18:54
API Blueprint error attributes example for Aglio
FORMAT: 1A
# Example API
This is an example showing error information like Stripe does.
## Errors
Errors returned by this API take the following format:
```json
{
@danielgtaylor
danielgtaylor / gist:0b60c2ed1f069f118562
Last active April 2, 2024 20:18
Moving to ES6 from CoffeeScript

Moving to ES6 from CoffeeScript

I fell in love with CoffeeScript a couple of years ago. Javascript has always seemed something of an interesting curiosity to me and I was happy to see the meteoric rise of Node.js, but coming from a background of Python I really preferred a cleaner syntax.

In any fast moving community it is inevitable that things will change, and so today we see a big shift toward ES6, the new version of Javascript. It incorporates a handful of the nicer features from CoffeeScript and is usable today through tools like Babel. Here are some of my thoughts and issues on moving away from CoffeeScript in favor of ES6.

While reading I suggest keeping open a tab to Babel's learning ES6 page. The examples there are great.

Punctuation

Holy punctuation, Batman! Say goodbye to your whitespace and hello to parenthesis, curly braces, and semicolons again. Even with the advanced ES6 syntax you'll find yourself writing a lot more punctuatio

@danielgtaylor
danielgtaylor / credentials.py
Created March 10, 2015 22:05
Credential Resolver Proposal
def create_credential_resolver(session):
"""Create a default credential resolver.
This creates a pre-configured credential resolver
that includes the default lookup chain for
credentials.
"""
profile_name = session.get_config_variable('profile') or 'default'
credential_file = session.get_config_variable('credentials_file')
@danielgtaylor
danielgtaylor / git diff
Created October 15, 2014 23:22
PEP8 Readability
diff --git a/tests/unit/resources/test_factory.py b/tests/unit/resources/test_factory.py
index 544ee61..2ef49c3 100644
--- a/tests/unit/resources/test_factory.py
+++ b/tests/unit/resources/test_factory.py
@@ -41,7 +41,7 @@ class TestResourceFactory(BaseTestCase):
self.factory.create_class('test')
self.assertTrue(self.factory.load_from_definition.called,
- 'Class was not loaded from definition')
+ 'Class was not loaded from definition')
@danielgtaylor
danielgtaylor / example.html
Last active May 17, 2019 08:10
Userbadges.com Example
<div class="profile">
<img src="/images/profile.jpg"/>
<h1>John Smith</h1>
Writer &amp; Reviewer<br/>Registered 1 Jan 2013
<h2>Awards:</h2>
<div class="userbadges" data-service="demo" data-user="jsmith"></div>
</div>
@danielgtaylor
danielgtaylor / 01-recipe.js
Last active December 17, 2015 06:59
Brauhaus.js examples
// Create a new recipe
var recipe = new Brauhaus.Recipe({
name: 'Daniel\'s Doppelbock',
description: '...',
author: 'Daniel G. Taylor'
batchSize: 20.0,
boilSize: 10.0
});
@danielgtaylor
danielgtaylor / index.html
Created May 13, 2013 16:05
Brauhaus.js getting started in the web browser
<html>
<head>
<title>Brauhaus.js Test</title>
</head>
<body>
<p>
Let's make some beer!
</p>
<script type="text/javascript" src="/scripts/brauhaus.min.js"></script>
<script type="text/javascript">
@danielgtaylor
danielgtaylor / mash-example.coffee
Created May 1, 2013 15:50
Brauhaus.js mashing example
Brauhaus = require 'brauhaus'
# Create a new recipe
recipe = new Brauhaus.Recipe
name: 'My new recipe'
batchSize: 20.0
# Add some grain to be mashed
recipe.add 'fermentable',
name: 'Pale malt'
@danielgtaylor
danielgtaylor / gist:5065626
Last active December 14, 2015 09:29
Calculating gravities, color, IBU, alcohol by volume, and calories for a beer recipe.
<script type="text/javascript" src="/scripts/brauhaus.min.js"></script>
<script type="text/javascript">
// Create a recipe
var r = new Brauhaus.Recipe({
name: 'My test brew',
description: 'A new test beer using Brauhaus.js!',
batchSize: 20.0,
boilSize: 10.0
});