Skip to content

Instantly share code, notes, and snippets.

@Stephenitis
Stephenitis / recursioninception.rb
Created March 28, 2013 20:21
recursion kitchen sink
# #How many different ways are there to flip a fair coin 5 times and not have three or more heads in a row?
# def combination(length=5)
# return [[]] if length == 0
# combination(length-1).collect {|c| [:h] + c } +
# combination(length-1).collect {|c| [:t] + c }
# end
# combination
# puts "*There are #{combination.length} ways"
# puts combination.inspect
@Stephenitis
Stephenitis / Sudoku columns.rb
Created March 31, 2013 05:20
working at setting up and transposing a sudoku board from the rows to the column format. pay attention to the letters and numbers in the transposed array
class SudokuBoard
attr_reader :rowdata, :columns
attr_writer :rowdata, :columns
def initialize(rowdata)
@rowdata = rowdata
@columns = create_columns
end
def create_columns
@columns = @rowdata.transpose
@Stephenitis
Stephenitis / Sudoku Columns Rows From String.rb
Last active December 15, 2015 15:09
sudoku columns and rows from a intial input(data) of a string or array of a Sudoku problem. testing the regex, use of instance variables
class SudokuBoard
attr_reader :rows, :columns, :data
attr_writer :rows, :columns, :data
def initialize(data)
if (data.respond_to? :join)
@data = data.join
else # If argument looks like an array of lines
@data = data
end

"SOLID Object-Oriented Design" by Sandi Metz @ GoRuCo 2009

Date: May 30, 2009

Video on confreaks.net

Notes

  • Design is all about dependencies
  • If you refer to something, you depend on it.
@Stephenitis
Stephenitis / image_scrape_3000.rb
Created April 18, 2013 21:48
Stephen's home built image scrapper.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'uri'
puts "what website would you like to scrape?"
link = gets.chomp
URL = link

Instructions:

  1. Download this application skeleton.
  2. Convert the app to use AJAX.
  3. Add any files you changed to your gist and submit your code.
@Stephenitis
Stephenitis / index.html
Created May 2, 2013 18:51 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@Stephenitis
Stephenitis / zoo.js
Last active December 16, 2015 22:09 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
function Animal(name, legs){
this.name = name,
this.legs = legs
}
Animal.prototype = {
identify: function(){
$(document).ready( function() {
setInterval(function(){
$(".frames").animate({
marginLeft: '-=100%'
},1000, function(){
$(this).find("li:last").after($(this).find("li:first"));
$(this).css({marginLeft:0});
})
},30);
});