Skip to content

Instantly share code, notes, and snippets.

View onomated's full-sized avatar

Onome Ufomata onomated

View GitHub Profile
@dblock
dblock / api_page_helper.rb
Created November 2, 2011 23:08
pagination helper with Grape
module ApiPageHelper
PAGINATE_OPTIONS = {
:default_page_size => 10
}
PAGINATE_PARAMS = [ "page", "offset", "size" ]
def paginate(coll, options = {})
options = PAGINATE_OPTIONS.merge(options)
if params[:page]
page = params[:page].to_i
size = (params[:size] || options[:default_page_size]).to_i
@dblock
dblock / api_logger.rb
Created December 10, 2012 01:43
API logger with Grape under Rails
class ApiLogger < Grape::Middleware::Base
def before
Rails.logger.info "[api] Requested: #{request_log_data.to_json}\n" +
"[api] #{response_log_data[:description]} #{response_log_data[:source_file]}:#{response_log_data[:source_line]}"
end
private
def request_log_data
@JeOam
JeOam / AutoLayout.md
Last active September 13, 2018 18:17
Auto Layout Tips

Auto Layout is a contraint-based, descriptive layout system. Describe the layout with constraints, and frames are calculated automatically.

Whay Auto Layout?

  • Relational: Codifying the relative way we describe interfaces
  • Dynamism: Improved responsiveness to changges
    • Metrics: iOS 6 to iOS 7, screen sizes, and rotation
      • The user can actually change the size of the font on the fly.
      • Using Auto Layout and using relationships to describe things like spacings, alignments, equal size, these are the things that are going to translate regardless of what the size of the container is, so the size of the control, the size of your contents. *Content: Localization