Skip to content

Instantly share code, notes, and snippets.

View uzaif313's full-sized avatar
🎯
Focusing

Uzaif uzaif313

🎯
Focusing
View GitHub Profile

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@uzaif313
uzaif313 / javascript_deep_dive.md
Created June 18, 2019 07:40 — forked from faressoft/javascript_deep_dive.md
JavaScript Deep Dive to Crack The JavaScript Interviews

update object

var state = {
    id: 1,
    points: 100,
    name: "Goran"
};

var newState = {
class Hash
def nested_each_pair
self.each_pair do |k,v|
if v.is_a?(Hash)
v.nested_each_pair {|k,v| yield k,v}
else
yield(k,v)
end
end
@uzaif313
uzaif313 / api_controller.rb
Created December 27, 2018 07:29 — forked from jimsynz/api_controller.rb
API Session Token Example
class ApiController < ApplicationController
skip_before_action :verify_authenticity_token
respond_to :json
rescue_from UserAuthenticationService::NotAuthorized, with: :not_authorized
rescue_from ActiveRecord::RecordNotFound, with: :not_found
before_filter :api_session_token_authenticate!
private
def signed_in?
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
# install openjdk
sudo apt-get install openjdk-7-jdk
# download android sdk
wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz
tar -xvf android-sdk_r24.2-linux.tgz
cd android-sdk-linux/tools
# install all sdk packages
@uzaif313
uzaif313 / _coding_challenge.md
Last active August 8, 2017 20:51 — forked from JohnBDonner/_coding_challenge.md
Coding Challenge

Description

Imagine we have a book model and chapter model. Both models have attributes that needs to have sanitized html. We use a gem called sanitizer to sanitize the text. Now how would you refactor this code to be more DRY and scalable? Bonus: How would you test this?

Directions:

  • Clone the gist
  • Modify the code (change these files or add your own)
  • Save your modifications as a forked gist
  • Respond to the Breezy email with a link to your gist
@uzaif313
uzaif313 / base_controller.rb
Created September 20, 2016 13:08 — forked from dhoelzgen/base_controller.rb
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'