Skip to content

Instantly share code, notes, and snippets.

View ChasevanHekken's full-sized avatar

Chase van Hekken ChasevanHekken

View GitHub Profile
// 1. Given a string containing a sentence (such as "Linode is really cool"), reverse each word in place, and then return the result.
function reverseWordsInPlace(sentence) {
let words = sentence.split(" ");
let reversedWords = [];
for (let i = 0; i < words.length; i++) {
let word = words[i].split("");
var reversedWord = [];
for (let k = word.length - 1; k > -1; k--) {
var fs = require('fs');
function sortAverages(averages) {
var sorted = [];
for (var account in averages) {
sorted.push([account, averages[account]]);
}
sorted.sort(function(a, b) {
return a[1] - b[1];
@ChasevanHekken
ChasevanHekken / gist:f9334e209fe3c7fff99a
Last active August 29, 2015 14:15
ActiveRecord Challenges
We'll be using [Storedom](https://github.com/turingschool-examples/storedom) for the following challenges.
Write ActiveRecord query statements for the following problems. You're welcome to change the schema to fit your needs. Create a gist to store your solutions. We'll pop them into Slack first thing Tuesday morning.
## Required
* Find all the items that have the word "elegant" in it.
1. Item.where("name like ?", "%Incredible%")
* Add three orders to a user.
2. Order.create(user_id: user.id)
@ChasevanHekken
ChasevanHekken / gist:c7183632c02d2f4cf4ad
Last active August 29, 2015 14:07
Send Method - New code
def find_by(attribute, criteria)
return if entries.nil?
entries.select { |entry| entry.send(attribute.to_sym) == criteria.downcase.capitalize }
end
@ChasevanHekken
ChasevanHekken / gist:aa7e52e31ceddf8c81f3
Created October 3, 2014 19:16
Send Method - Previous Code
def choose_attribute(attribute, criteria)
case
when attribute == "date"
find_by_date(criteria)
when attribute == "first_name"
find_by_first_name(criteria)
when attribute == "last_name"
find_by_last_name(criteria)
when attribute == "registration_date"
find_by_registration_date(criteria)
@ChasevanHekken
ChasevanHekken / 0.2.1-boggle_class_from_methods.rb
Last active August 29, 2015 13:56 — forked from dbc-challenges/0.2.1-boggle_class_from_methods.rb
phase 0 unit 2 week 1boggle class challenge
class BoggleBoard
attr_accessor :board
def initialize(board)
@board = board
end
def create_word(board, *coords)
coords.map { |coord| board[coord.first][coord.last]}.join("")
@ChasevanHekken
ChasevanHekken / gist:7927976
Created December 12, 2013 13:33
Object Oriented Blackjack Game
require 'rubygems'
require 'pry'
# Object Oriented Blackjack game
# 1) Abstraction
# 2) Encapsulation
class Card