Skip to content

Instantly share code, notes, and snippets.

View bsiqueira's full-sized avatar
👀

Bernardo Siqueira bsiqueira

👀
View GitHub Profile
class Person
attr_reader :name
attr_writer :name
def initialize(name)
@name = name
end
# def name
require 'active_support/all'
@candidates = [
{
id: 5,
years_of_experience: 4,
github_points: 293,
languages: ['C', 'Ruby', 'Python', 'Clojure'],
date_applied: 5.days.ago.to_date,
age: 26
def benchmark
benchmark_result = yield
start_time = Time.now
benchmark_result.reverse
end_time = Time.now
running_time = end_time - start_time
end
# Be careful, pasting this into IRB will take a long time to print.
# It's a loooong string. :)
class Library {
constructor(libraryName, creator){
this.libraryName = libraryName;
this.creator = creator;
this.playlists = [];
}
addPlaylist(playlist){
this.playlists.push(playlist)
}
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
function maxProfit(prices){
var maxProfit = prices[1] - prices[0];
var minPrice = prices[0];
for(var i = 1; i < prices.length; i++)
{
if (prices[i] - minPrice > maxProfit)
maxProfit = prices[i] - minPrice;
if (prices[i] < minPrice)
minPrice = prices[i];
}
function maxProfit(prices){
var maxProfit = prices[1] - prices[0];
var minPrice = prices[0];
for(var i = 1; i < prices.length; i++)
{
if (prices[i] - minPrice > maxProfit)
maxProfit = prices[i] - minPrice;
if (prices[i] < minPrice)
minPrice = prices[i];
}
function maxProfit(prices){
var maxProfit = 0;
for(var i = 0; i < prices.length; i++){
for(var j = 0; j < prices.length; j++){
if(i > j){
var possibleProfit = prices[i] - prices[j];
if (possibleProfit > maxProfit){
maxProfit = possibleProfit;
}
}