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 / 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 /
Last active Dec 18, 2015
Adding Test Suite In Rails -4 with rspec-3
In gem file
group :development, :test do
  gem 'rspec-rails', '~> 3.0.0'
  gem 'factory_girl_rails'
  gem 'capybara'
  gem 'database_cleaner'
ahmadhasankhan / AuthLogic with Ruby On
Last active Dec 20, 2015
Implementing user registration and session handling using AuthLogic in Rails 4 from scratch.
View AuthLogic with Ruby On

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 /
Created Dec 28, 2015
Rails server setup for production environment.

Deploy Ruby On Rails on Ubuntu 14.04

Server: Nginx with Phusion Passenger

Ruby Version: 2.1.3

User System: deploy

User System

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

  (0..k).each do |i|
    if (a[i] - position) <= d
ahmadhasankhan /
Last active Nov 19, 2017
Write a function which accepts an integer array and its size and modifies the array in the following manner.
# 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.
ahmadhasankhan /
Created Nov 25, 2017 — forked from jexchan/
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C ""
View 1_user.rb
class User < ApplicationRecord
has_many :posts
has_many :comments
# id :integer not null, primary key
# name :string(50) default("")
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:
# 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]
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDN3A4R4IpK9kVu9zf8Fh410FZJbTl8PZG6QgPi76jBINLoj3Vr1OAdfHEmopfIlaT4Ce4r3gk0SauTqkSwujCM9I+VzvejRBMOcUU9iW3tBVYpNfYeB856mHvB3DF3fVD6OtgufaKh6OkjPxfg7kU+xRWcana3X02631Z46/2ZY9gKqr4ao0WkLn+ylj9huKawJkwbvAzAb/ieG16ut0BwAmZUAF1tqtShfNY+1EbiJRWU7oP8h7YUM2p9x1zHw07NKhgf+HAZd8XAjbgup6qyegWhjeDWK/g3x4WyQMR2KNNA90iG2LiUHI/yiFcjWqDOrw9LJrXYqAYuSegN/NNJ ahmadhassan@ahmads-mbp
You can’t perform that action at this time.