Skip to content

Instantly share code, notes, and snippets.

@monicao
monicao / palindromes.rb
Last active December 14, 2015 17:08
Palindrome problem
# Returns true if sentence is a palindrome.
# racecar ---> true
# hello ---> false
# aba aba ---> true
# Never odd or even ---> true
def palindrome?(sentence)
# downcase the sentence
downcased_sentence = sentence.downcase
# remove all the spaces in the sentence
require_relative "hangman"
# figure out a random word to use for the game
class HangPlay
# Starts the hangman game
def self.start
@@game = Hangman.new("lemonade")
self.show_round
end
class Hangman
# This class will be used to run an instance of a hangman game
# It is only concerned with one run through of the game
# It is not responsible for human interaction
attr_accessor :word
attr_accessor :chances
attr_accessor :board
require_relative "hangman"
# figure out a random word to use for the game
class HangPlay
# Starts the hangman game
def self.start
@@game = Hangman.new("lemonade")
while true
require_relative "hang_play"
HangPlay.start
@monicao
monicao / dog.rb
Created March 13, 2013 19:41
An example of instance vs class variables
class Dog
# class variable
@@default_description = "A dog is a furry mammal."
attr_accessor :name
attr_accessor :age
attr_accessor :description
def initialize(name, description)
@monicao
monicao / gist:5565307
Created May 12, 2013 23:10
Angular minification settings for the asset pipeline
TestApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
config.assets.digest = true
config.assets.compile = false
config.assets.compress = true
@monicao
monicao / rails_testing.md
Last active June 22, 2021 16:55
Setting up rails 4 with MiniTest, Fabrication and Guard
# Gemfile
group :development, :test do
  gem 'minitest-rails'
  gem 'fabrication'
end
@monicao
monicao / tdd_notes.md
Last active May 22, 2017 11:35
TDD Lecture Notes

What is TDD?

  • write a test first
  • see it fail
  • write the implementation
  • see the test pass "the red green loop"

How much should you test?

@monicao
monicao / notes.md
Last active December 8, 2021 01:51
Setting up your own Ruby Dev Environment on a Mac

Setting up the Ruby dev environment on a Mac

Tested on Yosemite. Should work on El Cap. Message me if it doesn't.

Why would I want to do that?

  • You are tired of using vagrant
  • You want to run guard
  • You want use Sublime plugins (like RSpec or Guard plugins)
  • You want your code to run faster in development