Skip to content

Instantly share code, notes, and snippets.

View beelarr's full-sized avatar
🍩

Bryon Larrance beelarr

🍩
  • Software Development Consultant (React, Typescript, GraphQL, Next.js, CMS integration, Segment - GTM, Leanplum, Pixel Integration, Design Systems)
  • Remote
  • LinkedIn in/beelarr
View GitHub Profile
// Write an efficient method that takes stock_prices_yesterday and returns the best profit I could have made from 1 purchase and 1 sale of 1 Apple stock yesterday.
stock_prices = [12, 10, 7, 5, 8, 11, 9]
def get_max_profit quote
min_price = quote[0]
max_profit = min_price - quote[1]
quote.each_with_index do |price, index|
next if price.zero?
def fibonacci(n)
n <= 1 ? n : fibonacci( n - 1 ) + fibonacci( n - 2 )
end
puts fibonacci( 10 )
@beelarr
beelarr / gist:04d39a77acf2ca01fa5376e7681f7ddb
Created November 8, 2017 20:22 — forked from ryansobol/gist:5252653
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.

Box 3.1. Undoing things Even when you’re very careful, things can sometimes go wrong when developing Rails applications. Happily, Rails has some facilities to help you recover.

One common scenario is wanting to undo code generation—for example, when you change your mind on the name of a controller and want to eliminate the generated files. Because Rails creates a substantial number of auxiliary files along with the controller (as seen in Listing 3.6), this isn’t as easy as removing the controller file itself; undoing the generation means removing not only the principal generated file, but all the ancillary files as well. (In fact, as we saw in Section 2.2 and Section 2.3, rails generate can make automatic edits to the routes.rb file, which we also want to undo automatically.) In Rails, this can be accomplished with rails destroy followed by the name of the generated element. In particular, these two commands cancel each other out:

rails generate controller StaticPages home help

@beelarr
beelarr / Remove Node Modules
Created September 11, 2017 21:18
Remove Node Modules from Github repo
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
#!/usr/bin/env python
from bs4 import BeautifulSoup
from twilio.rest import TwilioRestClient
import json
import os
import re
import requests
url = 'https://postmates.com/los-angeles'
#!/usr/bin/env python
from bs4 import BeautifulSoup
from twilio.rest import TwilioRestClient
import json
import os
import re
import requests
url = 'https://postmates.com/los-angeles'