Skip to content

Instantly share code, notes, and snippets.

@venkatch789
venkatch789 / media-query.css
Created November 23, 2018 09:41 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@venkatch789
venkatch789 / character_set_and_collation.rb
Created January 30, 2018 07:45 — forked from tjh/character_set_and_collation.rb
Convert all Rails table column collation and character set
#!/usr/bin/env ruby
# Put this file in the root of your Rails project,
# then run it to output the SQL needed to change all
# your tables and columns to the same character set
# and collation.
#
# > ruby character_set_and_collation.rb
DATABASE = ''
##Create a migration
### rails g migration make_unicode_friendly
class MakeUnicodeFriendly < ActiveRecord::Migration
def change
alter_database_and_tables_charsets "utf8", "utf8_general_ci"
end
private
def alter_database_and_tables_charsets charset = default_charset, collation = default_collation
@venkatch789
venkatch789 / Test-Task
Created June 22, 2016 05:45 — forked from grouptable/Test-Task
A task that tests basic Ruby on Rails skills. It requires anywhere between 2-5 hours of your time.
* Create a clean ruby on rails application using twitter bootstrap.
* Create User model with fields first, last, email.
* Install and setup devise gem to use the User model for auth (email used as a user name).
* Generate devise views via rake command
* On the register new user view add a new text field called Secret Code.

Design patterns (in Ruby)

Design patterns are just tools that help us constructing a software.

Template Method pattern

In the Template Method pattern, we create a skeletal class and it is basis for various subclasses or concrete classes. Within in the skeletal class, there are abstract methods, which in turn, will be overridden by the methods of subclasses.

Let's take an example of simple payment system,

@Pramati - HYD (16/07/2015)

  1. What is your role and responsibilities in your current project?
  2. Find common elements from two arrays? Without using any Ruby operator and tell me how would you write a program?
  3. How to find an element from an array? How it internally works?
  4. How to sort ruby objects based on particular object? For ex: [@user1, @user2, @user3, @user4] - Then sort it by user's salary.
  5. Explain MVC?
  6. What is the use of moving controller code to model?
  7. Tell me the internal flow of execution when I call some method? For ex: @object.some_method
@venkatch789
venkatch789 / sql_views.rake
Created May 27, 2016 10:29 — forked from rietta/sql_views.rake
SQL Views rake task implementing `rake db:views`
namespace :db do
desc "Update and create SQL views"
task :views => :environment do
Dir["#{Rails.root}/db/sql_views/*.sql"].each do |file_name|
STDERR.puts "Applying the SQL view at #{file_name}"
source_file = File.new(file_name, 'r')
if source_file and (sql_content = source_file.read)
ActiveRecord::Base.transaction do
# Each statement ends with a semicolon followed by a newline.
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

What are the differences between procs and lambdas?

Before getting into the differences, they are very similar and both are Proc objects.

proc = Proc.new { puts "Hello world" }
lam = lambda { puts "Hello World" }

proc.class # returns 'Proc'
lam.class  # returns 'Proc'