Skip to content

Instantly share code, notes, and snippets.

View robvolk's full-sized avatar

Rob Volk robvolk

View GitHub Profile
@robvolk
robvolk / n_grams_code_challenge.md
Last active March 30, 2022 01:18
N-Grams Code Challenge

Foxbox Digital N-Grams Code Challenge

This is a small programming problem to test your technical ability and coding style.

Instructions

Write a simple script to generate a set of n-grams from a string of text. N-grams are a contiguous sequence of n words from a string of text, and have many applications from full-text search indexes to machine learning.

You'll generate a set of every permutation of contiguous n-grams from a string of text, from 1-gram to n-grams where n is the number of words in the string

Example

@robvolk
robvolk / enable_moped_logger.rb
Created August 18, 2015 17:14
See raw MongoDB queries from Mongoid / Moped by enabling Logger
# From Rails console, run the following and you'll see raw Moped queries for every Mongoid query!
Moped.logger = Logger.new(STDOUT)
@robvolk
robvolk / count_values_of_array.rb
Last active February 15, 2016 19:12
Count & sort values of a Ruby Array
food = ["bacon", "eggs", "cheese", "eggs", "bacon", "bacon", "bacon"]
food.inject(Hash.new(0)) {|h, k| h[k] += 1; h }.sort_by {|k,v| -1 * v}
# => [["bacon", 4], ["eggs", 2], ["cheese", 1]]
@robvolk
robvolk / rails_console_reload.rb
Created January 12, 2017 19:40
Reload file in lib on Rails Console
load "#{Rails.root}/lib/my_file.rb"