Skip to content

Instantly share code, notes, and snippets.

View afiq90's full-sized avatar
🏠
Working from home

Afiq afiq90

🏠
Working from home
  • Pluto at the moment
View GitHub Profile
@afiq90
afiq90 / Switch.swift
Created December 21, 2018 09:51 — forked from nathantannar4/Switch.swift
Re-Engineering UISwitch
//
// Switch.swift
// Re-Engineering UISwitch
//
// Created by Nathan Tannar on 15/12/18.
// Copyright © 2018 Nathan Tannar. All rights reserved.
//
import UIKit
@afiq90
afiq90 / places_controller.rb
Created July 31, 2015 09:09
places controller
module Api
module V1
class PlacesController < Api::ApiController # Api::BaseController
respond_to :json
before_action :authenticate #This authenticate method inherit from Api Controller
skip_before_action :verify_authenticity_token
def index
respond_with @user.places
@afiq90
afiq90 / rb
Created July 30, 2015 03:59
sessions_controller
class SessionsController < Devise::SessionsController
skip_before_filter :authenticate_user!, :only => [:create, :new]
skip_authorization_check only: [:create, :failure, :show_current_user, :options, :new]
respond_to :json
def new
self.resource = resource_class.new(sign_in_params)
clean_up_passwords(resource)
respond_with(resource, serialize_options(resource))
end
@afiq90
afiq90 / gist:ca1fd545821469f2865d
Created July 29, 2015 16:40
sessions_controller.rb
class SessionsController < Devise::SessionsController
before_filter :authenticate_user!, :except => [:create, :destroy]
respond_to :json
def create
resource = User.find_for_database_authentication(:email => params[:email])
return invalid_login_attempt unless resource
if resource.valid_password?(params[:password])
sign_in(:user, resource)
@afiq90
afiq90 / DidReceiveRemoteNotification Problem
Created January 17, 2015 13:35
DidReceiveRemoteNotification Problem
// Set the view to HotTableViewController when user tapped on remote notification
UIStoryboard *ab = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
HotTableViewController *hotArticle = [ab instantiateViewControllerWithIdentifier:@"hotArticle"];
UITabBarController *tabController = (UITabBarController *)self.window.rootViewController;
// tabController.selectedIndex = 0;
UINavigationController *navigationController = (UINavigationController *)tabController.selectedViewController;
[navigationController pushViewController:hotArticle animated:YES];