Skip to content

Instantly share code, notes, and snippets.

@smizell
smizell / vnd.error.xml
Created July 31, 2014 20:55
ALPS doc for defining semantics and links for error messages, as taken from the vnd.error media type
<alps version="1.0">
<descriptor id="error" type="semantic">
<doc>Error Message</doc>
<descriptor id="message" type="semantic">
<doc>
For expressing a human readable message related to the current error which may be displayed to the user of the api
</doc>
</descriptor>

Keybase proof

I hereby claim:

  • I am smizell on github.
  • I am smizell (https://keybase.io/smizell) on keybase.
  • I have a public key ASA6Hq_DyR581YFdOxPy9eU9ZS1gSHvaEZ8kW8u0DXp9WAo

To claim this, I am signing this object:

@smizell
smizell / gist:2511298
Created April 27, 2012 17:56
MySQL Backup Script (Bash)
#!/bin/sh
#backup all mysql databases
# list MySQL databases and dump each
DIR=/backup/mysql/
DATESTAMP=$(date +%Y%m%d)
DB_USER=mysqlbackup
DB_PASS=kate@racers#45
# remove old backups
find ${DIR} -type f -mtime +5 -exec rm -rf {} \;
@smizell
smizell / gist:2502461
Created April 26, 2012 19:43
API Call
window.MobileAppCollection = Backbone.Collection.extend
url: "http://kate.murraystate.edu/api/v1/mobile_app/"
model: MobileApp
window.MobileApp = Backbone.Model.extend
urlRoot: "http://kate.murraystate.edu/api/v1/mobile_app/"
url: () ->
base = @urlRoot || (@collection && @collection.url)
@smizell
smizell / get_query
Created March 27, 2012 15:51
Query String Templatetag
import urllib
from django import template
from django.conf import settings
register = template.Library()
class GetQuery(template.Node):
def __init__(self, query_dict, key, value):
@smizell
smizell / gist:611766
Created October 5, 2010 15:48
Chrome Frame Django Middleware
from django.conf import settings
class ChromeFrameMiddleware(object):
"""
Adds the Google Chrome Frame meta tag to your page
If you don't want it to check if Chrome Frame is installed,
put this in your settings.py file.
CHROME_CHECK = False

FORMAT: 1A

User Example

Example of reusing model

Group Users

User [/users/{id}]

  • Model (application/json)

Recursive HAL

There are a few steps you can take to simplify HAL even more than it is by making links recursive resources. It requires these changes.

  1. Add a _href property to be used to specify the URI of the resource. This would replace using self links.
  2. Change templated to _templated
  3. Change hreflang to _hreflang
  4. Change title to _title
  5. Consider links to be full HAL objects
<uber version="1.0">
<data rel="item" url="http://example.org/1">
<data name="givenName">Mike</data>
<data name="familyName">Amundsen</data>
<data name="hatsize">Medium</data>
<data name="update" action="replace" url="http://example.org/1">
<data name="familyName">
<data name="required">true</data>
</data>
<data name="givenName" />