Skip to content

Instantly share code, notes, and snippets.

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

Saroar Khandoker saroar

🏠
Working from home
View GitHub Profile
@saroar
saroar / gist:7e6a2f987d056ba7a9d5
Created February 24, 2015 22:38
mina deploy would u like to check please thanks advance
this is my deploy.rb
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv'
require 'mina_sidekiq/tasks'
require 'mina/unicorn'
# require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
@saroar
saroar / gist:dc40d4bf967fdcf77321
Created February 24, 2015 22:42
Set Up database.yml and secrets.yml
nano /home/deployer/YOUR_APP/shared/config/database.yml
nano /home/deployer/YOUR_APP/shared/config/secrets.yml
i have one quis also this two file need edit only on my server or i can edit in on my local computer also before mina deploy
Create a list of the intervals of the day.
Field 1: Beginning of the day (From, the time in 24-hour format)
Field 2: End of the working day (Till, the 24-hour format)
Field 3: Divider partition hour intervals (integer, usually divider 60)
Button: Create a list of slots
class CreateWorkingDays < ActiveRecord::Migration
def change
create_table :working_days do |t|
t.datetime :start_of_day
rails new test_app
cd test_app
echo "gem 'devise', '~> 3.0.0'" >> Gemfile
bundle install
rails g devise:views
gem install html2slim
for file in app/views/devise/**/*.erb; do erb2slim $file ${file%erb}slim; done
@saroar
saroar / gist:0818a369327b2174d7b356ba67a3a5f1
Created June 17, 2016 18:53
Polish Notation (RPN) Expression
# Тестовое задание
Для выполнения этого задания сделайте форк этого репозитория, и по готовности сделайте пулл реквест. Руби 2.2 и только std-lib
## Вычисление выражения в обратной польской записи
Написать программу, которая вычисляет выражения в обратной польской нотации.
Например, если на вход ей дать выражение 5 1 2 + 4 * + 3 - (что эквивалентно 5 + ((1 + 2) * 4) - 3 в нормальной записи), то она даст ответ 14. Валидными операциями являются +, -, \*, /, ^.
@saroar
saroar / refactor_from_omniaut.rb
Last active June 21, 2016 21:09
self.from_omniauth(auth, organisation) REFACTOR
# 3. Please refactor User#from_omniauth method. Currently it's hard to read. Please make it more clear.
def self.from_omniauth(auth, organization)
user = User.where(provider: auth.provider, uid: auth.uid).first
if user
return user
else
registered_user = User.where(email: auth.info.email).first
if registered_user
@saroar
saroar / capybara_cheat_sheet
Last active June 21, 2016 21:08
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')
@saroar
saroar / custom_validation.rb
Last active June 21, 2016 21:07
Custom Validation
class OrderItemsValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
raise 'Order must be one item from each menu!' unless each_menu?(value)
raise 'Items must be from today\'s menu!' unless contains_in_today_menu?(value)
raise 'Order can contain only one item for each menu!' unless only_one_per_menu?(value)
rescue Exception => e
record.errors[attribute] << (options[:message] || e.message)
end
private
@saroar
saroar / deploy_rails_app.rb
Last active July 7, 2017 14:18
Centos 7, NginX, Puma, Mina
# Deploy
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv'
set :rails_env, 'production'
set :deploy_to, 'deploy_location_without_current'
set :app_path, 'app_location'
set :user, 'alif'