Skip to content

Instantly share code, notes, and snippets.

View hjr3's full-sized avatar

Herman J. Radtke III hjr3

View GitHub Profile
@hjr3
hjr3 / nginx.conf
Created September 23, 2012 17:58
nginx phpfpm + CORS configuration
upstream phpfpm {
server 127.0.0.1:9000;
}
server {
listen 80;
server_name _;
root /var/www/html;
index index.php;
@hjr3
hjr3 / cache-control.md
Created October 17, 2012 00:34
HTTP examples for Cache-Control

Request for member resource

Request

GET /member/1234
Host: www.example.com

Response

HTTP/1.1 200 OK

@hjr3
hjr3 / post-credit.txt
Created November 5, 2012 05:16
Add credits to a members account.
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
}
@hjr3
hjr3 / result.json
Created November 20, 2012 21:47
v4 events response for nested child events
{
"_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"
@hjr3
hjr3 / truck.md
Created December 3, 2012 08:52
Example of HAL+json using truck as an example

Examples of HAL+json API calls for a truck

Get Trucks

GET /trucks HTTP/1.1
Host: api.example.com
Authorization: Basic username:password
Accept: application/hal+json
@hjr3
hjr3 / do-not-be-afraid-of-new-technology.md
Last active December 10, 2015 09:28
Do Not Be Afraid Of New Technology
@hjr3
hjr3 / thrush.rb
Created January 8, 2013 07:36
A basic way to formulate a Thrush
class Kernel
def let it
yield it
end
end
def cardinal_define(name, &proc_over_proc)
self.class.send(:define_method, name) do |a_value, &a_proc|
proc_over_proc.call(a_proc).call(a_value)
end
end
cardinal_define(:maybe) do |a_proc|
lambda { |a_value|
a_proc.call(a_value) unless a_value.nil?
}
@hjr3
hjr3 / datetime-scrum.md
Last active December 11, 2015 08:08
What do MySQL datetime types and scrum have in common?
@hjr3
hjr3 / rlimit.c
Last active December 12, 2015 07:58
How does setrlimit work when the value is 0?
/*
*
* gcc -o rlimit rlimit.c
*/
#include <sys/resource.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>