Skip to content

Instantly share code, notes, and snippets.

View acotie's full-sized avatar

Akiko Yokoyama acotie

View GitHub Profile
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager GET:@"http://localhost:3000/api/v1/tracks/1"
parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: manager %@", responseObject);
DDLogVerbose(@"Request Successful, responseObject '%@'", responseObject);
@acotie
acotie / entities.rb
Last active August 29, 2015 14:04
REST API sample by Grape & Grape::Entity. return nested items.
module TEST::Entities
class Post < Grape::Entity
expose :id
expose :title
expose :description
expose(:image_url) do |post, options|
if post.image.url.present? # else is return null
"http://#{options[:env]['HTTP_HOST']}"+"#{post.image.url}"
end
end
@acotie
acotie / eventmachine-defer.rb
Last active May 6, 2020 02:14
eventmachine defer sample.
require 'bundler/setup'
require 'eventmachine'
require 'open-uri'
EM.run do
puts "main: #{Thread.current}"
operation = proc {
puts "defer operation: #{Thread.current}"
sleep(20)
@acotie
acotie / Inconsolata-dz-Powerline.otf
Created January 17, 2018 03:01 — forked from qrush/Inconsolata-dz-Powerline.otf
vim-powerline patched fonts