Skip to content

Instantly share code, notes, and snippets.

View gregory's full-sized avatar
🎯
Focusing

Grégory Horion gregory

🎯
Focusing
View GitHub Profile
@gregory
gregory / stateable.rb
Created June 26, 2012 16:14 — forked from diegodurs/stateable.rb
Ruby stateable lib for ActiveRecord class
# Author: Diego d'Ursel
# ---------------------
#
# This simple lib help you to add state to a model without implementing boring functions for each state
# just add macro like "add_state 1, 'mystate'" to the definition of your ActiveRecord model
# this lib require a "state" field in the model
#
# some example of usage:
# ---------------------
# add_state 0, 'inactive'
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks
# of the ActiveRecord pattern. Several apps I have seen, and several
# developers I have spoken to are looking towards other patterns for object
# persistence. The major drawback with ActiveRecord is that the notion
# of the domain object is conflated with what it means to store/retrieve
# it in any given format (like sql, json, key/value, etc).
#
# This is an attempt to codify the Repository pattern in a way that would
# feel comfortable to beginner and seasoned Ruby developers alike.
#

Examples of RESTful API calls for E-commerce platforms

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.

Relevant links

@gregory
gregory / truck.md
Created February 17, 2014 18:49 — forked from hjr3/truck.md

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
@gregory
gregory / deploy.rb
Created March 3, 2014 17:55 — forked from dpsk/deploy.rb
# Capistrano configuration
#
# require 'new_relic/recipes' - Newrelic notification about deployment
# require 'capistrano/ext/multistage' - We use 2 deployment environment: staging and production.
# set :deploy_via, :remote_cache - fetch only latest changes during deployment
# set :normalize_asset_timestamps - no need to touch (date modification) every assets
# "deploy:web:disable" - traditional maintenance page (during DB migrations deployment)
# task :restart - Unicorn with preload_app should be reloaded by USR2+QUIT signals, not HUP

Deploy Rails 4 app with Dokku on DigitalOcean

Install dokku

First create a Ubuntu 13.04 x64 droplet on DigitalOcean Control Panel

Then ssh with root account, run this in termianl:

$ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
# using VirtualBox version $VBOX_VERSION
FROM boot2docker/boot2docker
RUN apt-get install p7zip-full
RUN mkdir -p /vboxguest && \
cd /vboxguest && \
curl -L -o vboxguest.iso http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso && \
7z x vboxguest.iso -ir'!VBoxLinuxAdditions.run' && \
sh VBoxLinuxAdditions.run --noexec --target . && \