GET /trucks HTTP/1.1
Host: api.example.com
Authorization: Basic username:password
Accept: application/hal+json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_links": { | |
"self": { | |
"href": "/v4/events/24057" | |
}, | |
"http://hautelook.com/rels/catalog": { | |
"href": "/v4/events/24057/catalog" | |
}, | |
"http://hautelook.com/rels/availability": { | |
"href": "/v4/events/24057/availability" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET /members/1234/credits HTTP/1.1 | |
Host: www.example.com | |
Content-Type: application/json | |
HTTP/1.1 200 OK | |
Content-Type: application/json | |
{ | |
credits: 10 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream phpfpm { | |
server 127.0.0.1:9000; | |
} | |
server { | |
listen 80; | |
server_name _; | |
root /var/www/html; | |
index index.php; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant::Config.run do |config| | |
# Every Vagrant virtual environment requires a box to build off of. | |
config.vm.box = "centos64-min" | |
# The url from where the 'config.vm.box' box will be fetched if it | |
# doesn't already exist on the user's system. | |
config.vm.box_url = "http://dl.dropbox.com/u/9227672/CentOS-6.0-x86_64-netboot-4.1.6.box" |
These examples are type 3 RESTful API requests and responses. The JSON-HAL specification is used to implement HATEOAS.
Some of the examples are based on my work as architect of the RESTful API at http://www.hautelook.com. All proprietary information has been removed.
- JSON-HAL specification: http://stateless.co/hal_specification.html#media_type_identifiers
- JSON linking with HAL: http://blog.stateless.co/post/13296666138/json-linking-with-hal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -std=c99 -Wall -Werror -g -o primes primes.c -lm | |
#include <stdio.h> | |
#include <string.h> | |
#include <limits.h> | |
#include <math.h> | |
void primes(int length) | |
{ | |
unsigned int bits_per_int = (sizeof(unsigned int) * CHAR_BIT); | |
unsigned int mask_size = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def xml_on_element(self, node): | |
if node.nodeName == 'property': | |
self.type = node.getAttribute('type') | |
name = node.getAttribute('name') | |
fullname = node.getAttribute('fullname') | |
if name == '': | |
name = 'EVAL_RESULT' | |
if fullname == '': | |
fullname = 'EVAL_RESULT' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -g -Wall -Werror -o decode decode.c | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
const int RESULT_LEN = 2; | |
/** | |
* Transforms a string of numerics in an array of ints. |