Skip to content

Instantly share code, notes, and snippets.

@roneesh
roneesh / gist:3988972
Created October 31, 2012 18:37 — forked from JeffCohen/gist:3986887
Week 5 Ruby Challenge
class Person
attr_accessor :name
attr_accessor :hometown
def bio
# Add code here
end
end
@roneesh
roneesh / Recursion.rb
Created December 4, 2012 07:32
Examples of recursion
#RECURSION EXERCISES
# BASIC RECURSION FACTORIAL FUNCTION
def factorial(n)
#termination case
if n < 0
return puts "You can't factorial a negative number!"
end
@roneesh
roneesh / FizzBuzz.rb
Created December 4, 2012 08:26
A solution of the classic FizzBuzz problem
#FIZZ BUZZ
#Counts up from 1 to 100
#puts 'fizz' if the number is divisible by 3
#puts 'buzz' if the number is divisible by 5
#puts 'fizzbuzz' if the number is divisible by 3 and 5
(1..100).each do |number|
if (number % 3 == 0) && (number % 5 == 0)
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://www.zurb.com/playground/javascripts/plugins/jquery.annotate.js"></script>
<style type="text/css">
.black {
background: black;
height: 5px;
width: 5px;
<%= form_for [@user, @project] do |f| %>
<% if @project.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@project.errors.count, "error") %> prohibited this project from being saved:</h2>
<ul>
<% @project.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
The stack:
OS
Web server
application server
database server
more.... (caching, any tools to keep an up and running)
A fresh rails development stack:
Mac OSX - WEBrick - SQLite
.two-column {
-moz-column-count: 2; /* Firefox */
-webkit-column-count: 2; /* Safari and Chrome */
column-count: 2;
-moz-column-gap:40px; /* Firefox */
-webkit-column-gap:40px; /* Safari and Chrome */
column-gap:40px;
}
@roneesh
roneesh / gist:6136641
Last active December 20, 2015 13:09
The Exercism.io word-count problem: Write a program that given a phrase can count the occurrences of each word in that phrase. For example for the input `"olly olly in come free"` ```plain olly: 2 in: 1 come: 1 free: 1 ```
# Where I ended up...
class Phrase < String
def word_count
words.each_with_object(Hash.new(0)) { |word, word_count| word_count[word] += 1 }
end
def words
downcase.scan(/\w+/)
@roneesh
roneesh / gist:6136677
Created August 2, 2013 00:46
RNA Transcription problem from exercism.io Write a program that can translate a given DNA string to the transcribed RNA string corresponding to it. An RNA string is a string formed from the alphabet containing 'A', 'C', 'G', and 'U'. Given a DNA string t corresponding to a coding strand, its transcribed RNA string u is formed by replacing all oc…
# Where I ended up...
class DNA < String
def to_rna
tr('T','U')
end
end
@roneesh
roneesh / gist:6136696
Last active December 20, 2015 13:09
Exercise 1 from Exercism.io - Bob Bob answers 'Sure.' if you ask him a question. He answers 'Whatever.' if you tell him something. He answers 'Woah, chill out!' if you yell at him (ALL CAPS). He says 'Fine. Be that way!' if you address him without actually saying anything.
# Where I ended up...
class Bob
def hey input
talking = Phrase.new(input)
return 'Fine. Be that way.' if talking.silent?
return 'Woah, chill out!' if talking.yelling?