Skip to content

Instantly share code, notes, and snippets.

View prathe's full-sized avatar

Philippe Rathé prathe

  • Remote, North America
View GitHub Profile
@prathe
prathe / Highlights-on-REST.markdown
Created March 3, 2012 02:17
Highlights on REST

Highlights on REST

By Roy Fielding himself

Quotes have been taken from Roy Fielding's blog posts writings and own comments.

A REST API should spend almost all of its descriptive effort in defining the media type(s) used for representing resources and driving application state, or in defining extended relation names and/or hypertext-enabled mark-up for existing standard media types. Any effort spent describing what methods to use on what URIs of interest should be entirely defined within the scope of the processing rules for a media type (and, in most cases, already defined by existing media types). [Failure here implies that out-of-band information is driving interaction instead of hypertext.]

@prathe
prathe / gist:1910116
Created February 25, 2012 19:06
Installing gcc from sources on OSX
# Grab and unpack the tarball
$ mkdir -p ~/src && cd ~/src
$ curl -O http://opensource.apple.com/tarballs/gcc/gcc-5666.3.tar.gz
$ tar zxf gcc-5666.3.tar.gz
$ cd gcc-5666.3
# Setup some stuff it requires
$ mkdir -p build/obj build/dst build/sym
# And then build it. You should go make a cup of tea or five whilst this runs.
$ sudo gnumake install RC_OS=macos RC_ARCHS='i386 x86_64' TARGETS='i386 x86_64' \
<%= form_for @timesheet, :builder => TimesheetFormBuilder do |timesheet_form| %>
<%= timesheet_form.fields_for :worklogs do |worklog_form| %>
<%= worklog_form.text_field :monday %>
<% end %>
<% end %>
state_machine :state, initial: :opened do
state :opened
state :confirmed
state :rejected
state :closed
event :confirm_it do
# only user
transition [:opened, :rejected] => :confirmed
@prathe
prathe / gist:1628799
Created January 17, 2012 20:51
BigDecimal#to_s without trailing zero
class BigDecimal
def to_s(s = 'F')
sign, significant_digits, base, exponent = self.split
if self.zero?
'0'
elsif significant_digits.size <= exponent
self.to_i.to_s
else
self.to_f.to_s
end
@prathe
prathe / gist:1398482
Created November 27, 2011 23:50
Managing websites locally with POW

Disable Web sharing

In System Prefecences under Sharing, uncheck "Web Sharing". You probably won't need it anymore.

Update to the latest XCode

Install MySQL with homebrew

brew update
brew install mysql
Feature: User login
Scenario: User is greeted upon login
Given a user with an account
When he logs in
Then he should be greeted