Skip to content

Instantly share code, notes, and snippets.

View mAlishera's full-sized avatar

Ekaterina mAlishera

  • Berlin, Germany
View GitHub Profile

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.

@mAlishera
mAlishera / input_maska_spec.rb
Last active August 29, 2015 14:24
input_maska_spec.rb
def maskarad(input, maska)
input = input.to_s.chars
maska.gsub(/@/) do |at|
input.shift
end.gsub(/^-*/, '').gsub(/-*$/, '') + input.join
end
=begin Input data
Маска | Номер | Результат
@mAlishera
mAlishera / ecto_migration.exs
Created January 23, 2017 22:15
Composite primary key in Ecto
defmodule Messaging.Repo.Migrations.CreateGroupChatVersions do
use Ecto.Migration
def change do
create table(:group_chat_versions, primary_key: false) do
add :group_chat_id, :uuid, primary_key: true
add :version, :integer, primary_key: true
timestamps
end
@mAlishera
mAlishera / create_users.rb
Created January 23, 2017 22:35
timestamps in AR
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
...
t.datetime 'inserted_at', null: false
t.datetime 'updated_at', null: false
end
end
end
@mAlishera
mAlishera / Gemfile
Created January 23, 2017 23:09
Composite primary key with ActiveRecord
...
gem 'composite_primary_keys', '=8.1.5'
...
@mAlishera
mAlishera / application.rb
Created February 18, 2017 16:51
Adding custom middleware
...
class Application < Rails::Application
...
config.middleware.insert_before "ActionDispatch::Callbacks", "MyMiddleware"
...
...
@mAlishera
mAlishera / my_middleware.rb
Created February 18, 2017 17:02
MyMiddleware with PG::ConnectionBad rescue
class MyMiddleware
def initialize(app)
@app = app
end
def call(env)
dup._call(env)
end
def _call(env)
@mAlishera
mAlishera / configs_controller.rb
Last active February 20, 2017 15:18
Skip token verification
class ConfigsController < ApplicationController
skip_before_filter :verify_authenticity_token, only: [:create, :new]
...
end
int main(int argc, const char * argv[]) {
int num, new_num(0), i(0), new_i(0), temp_i;
printf("введите x\n");
scanf("%i", &num);
temp_i = i;
while (i <= num) {
while (i) {
new_i = i*10 + (i % 10);
i = i/10;
//
int x;
int d[] = {3, 4, 5, 6};
x = d[2] + 3*d[3];
const int N = 10;
int i, a[N];
for(i=0; i<N; i++) {
printf("Введите a[%d]: ", i)
scanf("%d\n", &a[i]);