Skip to content

Instantly share code, notes, and snippets.

@zumbojo
zumbojo / bijective.rb
Created July 9, 2011 22:09
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
@ryansobol
ryansobol / gist:5252653
Last active November 22, 2023 11:53
15 Questions to Ask During a Ruby Interview

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.

Tech Interview Questions

Linked List

Implement a linked list in Ruby

class Node
  def initialize(data)
 @data = data
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active June 18, 2024 20:30
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

anonymous
anonymous / join_clinic.sql
Created March 4, 2015 16:11
SQL JOIN CLINIC
-- TABLE A
SELECT * FROM A;
-- id | name
-- ----+-------
-- 1 | bob
-- 2 | jill
-- 3 | frank
-- TABLE B
SELECT * FROM B;
@rayhamel
rayhamel / cheatsheet.md
Last active August 14, 2016 16:52
Ray's Algorithms and Interview Questions Cheat Sheet!

ALGORITHMS AND INTERVIEW QUESTIONS CHEAT SHEET

DATA STRUCTURES

A data structure is a group of data organized in the computer's memory by certain specific rules defining predictable relationships between the data. Arrays, hashes and relational databases are all examples of data structures.

@karimmtarek
karimmtarek / rails_interview_question.md
Last active August 29, 2015 14:18
Ruby on Rails interview questions

#Ruby on Rails Interview Questions

What is CSRF and how do you prevent it?
What are strong parameters introduced in Rails 4 and what is the reasoning behind the change?
Explain how you test your Rails app. Explain the various test levels available out of the box (controllers/integration/mailers/models).
What is a Rails engine?
What are different ways you could modularize a huge Rails app?
What code would you put in app/controllers/concern?
What does “keep your controllers thin and your models fat” mean?
How would you remove logic from your views?
When would you use a class vs instance variables in RoR ?
@zcaceres
zcaceres / Include-in-Sequelize.md
Last active January 8, 2024 07:14
using Include in sequelize

'Include' in Sequelize: The One Confusing Query That You Should Memorize

When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).

When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.

Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.

So let's go through the one query that's worth memorizing to handle your eager loading.

The Basic Query