Skip to content

Instantly share code, notes, and snippets.

View whalec's full-sized avatar

Cameron Barrie whalec

View GitHub Profile
require 'api_version'
Securus::Application.routes.draw do
match "/bb_poc" => "bb_poc#index"
scope "(:locale)", :locale => /ar|de|en|fr|it|nl|sr/ do
resource :session, :only => [:new, :create, :destroy]
resource :profile, :only => [:show, :edit, :update]
resources :users, :only => [:new, :create] do
require 'net/http/post/multipart'
def file=(_file)
url = URI.parse(<Your endpoint>)
File.open(_file) do |f|
req = Net::HTTP::Post::Multipart.new url.path, "file" => UploadIO.new(f, "image/jpeg", "filename")
res = Net::HTTP.start(url.host, url.port) do |http|
http.request(req)
end
end
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
__block UIView *searchLabel = [self.filterScrollingView viewWithTag:kSearchLabel];
[UIView animateWithDuration:15. delay:0. options:(UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveLinear) animations:^{
searchLabel.center = CGPointMake(-searchLabel.bounds.size.width / 2, searchLabel.center.y);
} completion:nil];
}
{
name : "Cams custom view",
columns : [
"name", "hits", "created_at"
],
filters : [
{action : "name='Cam'"},
{action : "hits>12"}
],
order : [{action : "hits DESC"}, {action : "created_at DESC"}]
@timeline.map do |post|
{
:id => post.id,
:brand => {
:id => post.brand.id,
:name => post.brand.name,
:updated_at => post.brand.updated_at,
:attachments => post.brand.images.map do |image|
{
:id => image.id,
@whalec
whalec / attachments.rb
Created August 6, 2011 04:32
Ruby Module implementation
module Attachments
def attachments
images.map do
{
:id => id,
:styles => styles,
:endpoint => endpoint,
}
end
@whalec
whalec / attachment.json
Created August 6, 2011 04:06
Initial thoughts on the attachment API response
//An attachment representation
{
"id" : 4
"endpont" : "http://s3.amazonaws.com/sns-bucket/production/images/"
"file" : "file.png",
"styles" : [
{"name" : "icon"},
{"name" : "small"},
{"name" : "small@2x"}
@whalec
whalec / timeline.json
Created August 3, 2011 13:45
suggested API view for /timeline.json
[
{
"id":2504,
"brand": {
"name" : "20000000 fragments",
"images" : {
"style":"icon",
"url":"http://s3.amazonaws.com/sns-bucket/production/images/4/icon/file.png?1310604103",
"updated_at":"2011-07-14T00:41:44Z",
}
RKManagedObjectMapping *postMapping = [RKManagedObjectMapping mappingForEntityWithName:@"MRNPost"];
postMapping.primaryKeyAttribute = @"postID";
[postMapping mapKeyPath:@"id" toAttribute:@"postID"];
[postMapping mapKeyPath:@"url" toAttribute:@"url"];
[postMapping mapKeyPath:@"content" toAttribute:@"content"];
[postMapping mapKeyPath:@"created_at" toAttribute:@"createdAt"];
[postMapping mapKeyPath:@"updated_at" toAttribute:@"updatedAt"];
[postMapping mapKeyPath:@"images" toRelationship:@"images" withObjectMapping:postImageMapping];
@whalec
whalec / images.json
Created July 22, 2011 03:50
Images API
"images" : [
{
"id":4,
"updated_at" : "2011-07-14T00:41:44Z",
"attachments": [
{
"style" : "icon",
"url" : "http://s3.amazonaws.com/sns-bucket/production/images/4/icon/file.png"
},
{