Skip to content

Instantly share code, notes, and snippets.

@osha7
osha7 / og-specs.md
Last active July 6, 2020 15:36 — forked from dwyn/og-specs.md
OG Rails Project Specs

Specifications for the Rails Assessment

Specs:

  • Using Ruby on Rails for the project
  • Include at least one has_many relationship (x has_many y; e.g. User has_many Recipes)
  • Include at least one belongs_to relationship (x belongs_to y; e.g. Post belongs_to User)
  • Include at least two has_many through relationships (x has_many y through z; e.g. Recipe has_many Items through Ingredients)
  • Include at least one many-to-many relationship (x has_many y through z, y has_many x through z; e.g. Recipe has_many Items through Ingredients, Item has_many Recipes through Ingredients)
  • The "through" part of the has_many through includes at least one user submittable attribute, that is to say, some attribute other than its foreign keys that can be submitted by the app's user (attribute_name e.g. ingredients.quantity)
  • Include reasonable validations for simple model objects (list of model objects with validations e.g. User, Recipe, Ingredient, Item)
let arr = [1, 5, 14, 23, 27, 32, 40, 54, 59, 67, 73]
let target = 54
let binarySearchFunction = function(arr, target) {
let leftPointer = 0
let rightPointer = arr.length - 1
return -1
}
let arr = [1, 5, 14, 23, 27, 32, 40, 54, 59, 67, 73]
let target = 54
let binarySearchFunction = function(arr, target) {
let leftPointer = 0
let rightPointer = arr.length - 1
while (leftPointer <= rightPointer) {
let med = Math.ceil((rightPointer + leftPointer) / 2)
let arr = [1, 5, 14, 23, 27, 32, 40, 54, 59, 67, 73]
let target = 54
let binarySearchFunction = function(arr, target) {
let leftPointer = 0
let rightPointer = arr.length - 1
while (leftPointer <= rightPointer) {
let med = Math.ceil((rightPointer + leftPointer) / 2)
@osha7
osha7 / stack - 1
Last active February 28, 2021 00:09
const stack = []
// add items to the stack:
stack.push('Batman')
stack.push('Spider-Man')
stack.push('Wonder Woman')
stack.push('Black Panther')
stack
// ==> ['Batman', 'Spider-Man', 'Wonder Woman', 'Black Panther']
@osha7
osha7 / stack - 2
Last active February 28, 2021 01:23
class Stack {
constructor() {
this.data = {}
this.size = 0
}
// add an element
push(element) {
this.size++
const superheroStack = new Stack()
superheroStack.push('Batman')
superheroStack.push('Wonder Woman')
superheroStack.push('Black Panther')
superheroStack.push('Spider-man')
superheroStack
//===> Stack { storage: { '1': 'Batman', '2': 'Wonder Woman', '3': 'Black Panther', '4': 'Spider-man' }, size: 4 }
@osha7
osha7 / queue - 1
Last active February 28, 2021 00:42
queue - 1
const queue = []
// add items to the queue:
queue.push('strength')
queue.push('invisibility')
queue.push('shapeshifting')
queue.push('teleportation')
queue
// ==> ['strength', 'invisibility', 'shapeshifting', 'teleportation']
class Queue {
constructor() {
this.data = {}
this.head = 0
this.tail = 0
}
enqueue(element) {
this.data[this.tail] = element
this.tail++