Skip to content

Instantly share code, notes, and snippets.

View rakibulislam's full-sized avatar
🎯
Focusing

K M Rakibul Islam (Rakib) rakibulislam

🎯
Focusing
View GitHub Profile
diff --git a/Gemfile b/Gemfile
index 91fe5bc..26f694c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -45,3 +45,5 @@ end
gem 'rails_admin'
+gem 'database_cleaner'
+
class CommentsController < ApplicationController
def index
@post = Post.find(params[:post_id])
@comments = @post.comments
end
def show
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
end
away_team_abbrv
away_team_uri
home_team_abbrv
home_team_uri
score_summary_abbrv
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "minitest/reporters"
Minitest::Reporters.use!
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
@rakibulislam
rakibulislam / common_items_in_two_list.erl
Created October 25, 2015 17:30
common_items_in_two_list.erl
list1 = [1,2,3,4,5]
list2 = [2,3,6]
Set.intersection(Enum.into(list1, HashSet.new), Enum.into(list2, HashSet.new))
# => HashSet<[2, 3]>
Set.intersection(Enum.into(list1, HashSet.new), Enum.into(list2, HashSet.new)) |> Set.to_list
# => [2, 3]
one:
email: [email protected]
password:
two:
email: [email protected]
password:
@rakibulislam
rakibulislam / deploy.rake
Created November 11, 2015 17:45 — forked from njvitto/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
#Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU'
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU'
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag]
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on]
@rakibulislam
rakibulislam / server_setup.sh
Created January 1, 2016 06:32 — forked from deepakkumarnd/server_setup.sh
Server setup script
echo "* Updating system"
apt-get update
apt-get -y upgrade
echo "* Installing packages"
apt-get -y install build-essential libmagickcore-dev imagemagick libmagickwand-dev libxml2-dev libxslt1-dev git-core nginx redis-server curl nodejs htop
id -u deploy &> /dev/null
if [ $? -ne 0 ]
then
@rakibulislam
rakibulislam / bijective.rb
Created March 20, 2016 02:37 — forked from zumbojo/bijective.rb
Simple bijective function (base(n) encode/decode)
# Simple bijective function
# Basically encodes any integer into a base(n) string,
# where n is ALPHABET.length.
# Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047
ALPHABET =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//)
# make your own alphabet using:
# (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join
@rakibulislam
rakibulislam / capybara cheat sheet
Created July 14, 2016 14:44 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')