Skip to content

Instantly share code, notes, and snippets.

👨‍💻
💯

Ahmad Hassan ahmadhasankhan

👨‍💻
💯
Block or report user

Report or block ahmadhasankhan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ahmadhasankhan
ahmadhasankhan / database.yml.example Oracle
Created Sep 3, 2014
Rails 4 database.yml config files.
View database.yml.example Oracle
# Oracle/OCI 8i, 9, 10g
#
# Requires Ruby/OCI8:
# http://rubyforge.org/projects/ruby-oci8/
#
# Specify your database using any valid connection syntax, such as a
# tnsnames.ora service name, or an SQL connect string of the form:
#
# //host:[port][/service name]
#
View rails-style-guide.md

The Rails Style Guide

This Rails style guide recommends best practices so that real-world Rails programmers can write code that can be maintained by other real-world Rails programmers. A style guide that reflects real-world usage gets used, and a style guide that holds to an ideal that has been rejected by the people it is supposed to help risks not getting used at all – no matter how good it is.

The guide is separated into several sections of related rules. I've tried to add

@ahmadhasankhan
ahmadhasankhan / db_backup.rb
Last active Aug 29, 2015
MySQL DB backup script in Ruby CMD
View db_backup.rb
#1===========First code================
#!/usr/bin/env ruby
databases = {
:local_db => {
:database => 'my_db',
:username => 'root',
:password => 'admin',
:host => 'localhost'
@ahmadhasankhan
ahmadhasankhan / AddTestSuiteInRails.md
Last active Dec 18, 2015
Adding Test Suite In Rails -4 with rspec-3
View AddTestSuiteInRails.md
In gem file
group :development, :test do
  gem 'rspec-rails', '~> 3.0.0'
  gem 'factory_girl_rails'
  gem 'capybara'
  gem 'database_cleaner'
end
@ahmadhasankhan
ahmadhasankhan / Ruby and Rails Interview Cheat Sheet.md
Last active Apr 8, 2019
This is my Ruby interview cheat sheet. Feel free to fork it, Use it, Share it, or do whatever you want with it. PLEASE let me know if there is any error or if anything crucial is missing. I will keep updating...
View Ruby and Rails Interview Cheat Sheet.md

Ruby and Rails Interview Questions

Ruby

  • What is a class?
  • What is an object?
  • What is a module? Can you tell me the difference between classes and modules?
  • Can you tell me the three levels of method access control for classes and modules? What do they imply about the method?
  • There are three ways to invoke a method in ruby. Can you give me at least two?
  • Explain this ruby idiom: a ||= b
@ahmadhasankhan
ahmadhasankhan / AuthLogic with Ruby On Rails-4.md
Last active Dec 20, 2015
Implementing user registration and session handling using AuthLogic in Rails 4 from scratch.
View AuthLogic with Ruby On Rails-4.md

AuthLogic with Ruby On Rails-4

Implementing user registration and session handling using AuthLogic in Rails 4 from scratch.

Follow along:

Create a new rails application-

$ rails new login_application
$ cd login_application
$ vim Gemfile
@ahmadhasankhan
ahmadhasankhan / RailsDeployment.md
Created Dec 28, 2015
Rails server setup for production environment.
View RailsDeployment.md

Deploy Ruby On Rails on Ubuntu 14.04

Server: Nginx with Phusion Passenger

Ruby Version: 2.1.3

User System: deploy

User System

@ahmadhasankhan
ahmadhasankhan / frog_problem.md
Created Feb 11, 2016
Frog Interview Problem
View frog_problem.md
def solution(a, x, d)
  k = a.size
  position = 0
  if position+d >= x
    return 0;
  end

  (0..k).each do |i|
    if (a[i] - position) <= d
@ahmadhasankhan
ahmadhasankhan / MySql-5.5-installation guide.md
Last active Sep 14, 2019
Install MySQL 5.5.xx on Ubuntu
View MySql-5.5-installation guide.md

MySQL Download URL

https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz

Open the terminal and follow along:

  • Uninstall any existing version of MySQL
sudo rm /var/lib/mysql/ -R
@ahmadhasankhan
ahmadhasankhan / modifies_the_array.md
Last active Nov 19, 2017
Write a function which accepts an integer array and its size and modifies the array in the following manner.
View modifies_the_array.md
# 1) If the elements of index i and (i+1) are equal then, double the value at index i
# and replace the element at index (i+1) with 0.
# 
#     2) If the element at index i is 0, then ignore it.
# 
#     3) Any number (element in an array) must be modified only once.
# 
#     4) At the end, shift all the zeros (0s) to the right of the array and remaining
# nonzeros to the left of the array.
You can’t perform that action at this time.