Skip to content

Instantly share code, notes, and snippets.

View alexvbush's full-sized avatar

Alex Bush alexvbush

View GitHub Profile
import { AxiosInstance } from "axios";
import RxAxios from 'axios-observable';
import { delay, map, Observable, of, Subscription } from "rxjs";
export class Session {
constructor(
readonly accessToken: string,
readonly client: string,
readonly uid: string,
readonly expiry: string
import Foundation
protocol User {
var firstName: String { get }
var lastName: String { get }
func fullName() -> String
}
class CurrentUser: User {
import Foundation
struct User {
let firstName: String
let lastName: String
func fullName() -> String {
return "\(firstName) \(lastName)"
}
}
import Foundation
// this is either a third party SDK interface or your own analytics client implementation
// that actually sends JSON across the wire to deliver tracked analytics events
protocol AnalyticsClient {
func sendAnalyticsDataToTheBackend(_ eventJSON: [String: Any])
}
final class ConcreteAnalyticsClient: AnalyticsClient {
func sendAnalyticsDataToTheBackend(_ eventJSON: [String: Any]) {
@alexvbush
alexvbush / HLPlaceResourceManager.h
Last active August 29, 2015 14:10
RestKit RKObjectManager Setup
//
// HLPlaceResourceManager.h
// HeyLets2
//
// Created by Alex Bush on 11/18/14.
// Copyright (c) 2014 HeyLets. All rights reserved.
//
#import <Foundation/Foundation.h>
@alexvbush
alexvbush / boolean_value.rb
Last active August 29, 2015 14:04
Global Settings for storing app configuration(with caching)
class BooleanValue < Value
end
def for_scope(scope, user = GuestUser.new)
case scope
when 'saved'
user.saved_articles.scoped
when 'my'
user.tagged_articles.scoped
else
scoped
end
end
@alexvbush
alexvbush / article.rb
Created July 14, 2014 02:06
Final version of Article model.
class Article < ActiveRecord::Base
include Categorizable
APPROVED = 'approved'
PENDING = 'pending'
REJECTED = 'rejected'
attr_accessible :approved_at, :url, :body, :image, :rating, :state, :title, :news_source_id, :published_at
validates :url, :uniqueness => true
@alexvbush
alexvbush / articles_controller.rb
Created July 14, 2014 02:04
Final version of Articles controller.
class Api::Private::ArticlesController < Api::Private::BaseController
include ArticlesSearch
before_filter :find_or_create_article, except: [:index]
PAGE_SIZE = 20
attr_accessor :total_pages
def index
@articles = Article
@alexvbush
alexvbush / article.rb
Last active August 29, 2015 14:03
Second iteration of Article model.
class Article < ActiveRecord::Base
include Categorizable
APPROVED = 'approved'
PENDING = 'pending'
REJECTED = 'rejected'
attr_accessible :approved_at, :url, :body, :image, :rating, :state, :title, :news_source_id, :published_at
validates :url, :uniqueness => true