This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SOLUTION 1) | |
Array.prototype.each_slice = function (size, callback){ | |
console.log(this.length, 'Size', size, 'Callback', callback); | |
for (var i = 0, l = this.length; i < l; i += size){ | |
callback.call(this, this.slice(i, i + size)); | |
} | |
}; | |
var Crypto = function(secretMessage){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#script tags are blocking operations, it cant do anything until it gets the script back; | |
#Remember it has to request all of the script links individually from the server; | |
#On heroku it will only include one script file and one css file which will be much faster as doesnt have to make lots of request to the server; | |
#It is hard to debug stuff on heroku; | |
#You can ask rails to run the production environment locally; | |
rails server -e production #If you are having a problem that only appears in production, you can make the production environment run locally; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
var alphabet = _.range(65, 65 + 26).map(function(i){ | |
return String.fromCharCode(i) | |
}); | |
var numbers = _.range(100, 1000); | |
var robotFactory = function(){ | |
var robot = { | |
instructionCount: 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'rails-rspec' | |
rails g rspec:install | |
rake db:test:clone #clone the development into test; #We have the same database in development and test environment; | |
x = Fruit.find(1) | |
x.class => Fruit | |
#type is a magic word that is used in single table inheritance; | |
#User models may use single table inheritance; | |
#The admin user will have fewer permissions; | |
#The guest user will have fewer permissions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'minitest/pride' | |
require_relative './hexadecimal' | |
class HexadecimalTest < MiniTest::Unit::TestCase | |
def test_hex_1_is_decimal_1 | |
assert_equal 1, Hexadecimal.new("1").to_decimal | |
end | |
def test_hex_c_is_decimal_12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#test, fixtures, tweets.yml | |
#You can create seed data very quickly; | |
gem 'factory-girl-rails' | |
#Going to create a factory that makes twweets | |
#In test folder create factories.rb | |
#In here we will have a tamplate for creating a user; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pry' | |
binding.pry | |
ruby reader.rb groucho harpo chico #Ruby load this file and pass in 3 arguments; | |
ARGV #This is the argments array that you passed into the programme when you ran it; | |
puts ARGV.join(', ') | |
if(ARGV[0] == 'groucho') | |
puts "Hey there Groucho" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby roman.rb | less #send the output to another programme called less, when you are inside less you have a colon at the bottom; | |
ruby roman.rb > romans.txt | |
less romans.txt | |
#In javascrpt you need an array of objects; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rake -T | |
#You can create your own tasks that will make your life easier; | |
#Source code files get compiled into object files and these get compiled into machine language; | |
#Describe in MAKE how to make the files, pays attention to what time the files were updates; | |
#Sinatra is a DSL lets you use a version of Ruby; | |
#Rake; #B | |
#Rake looks in the current directory for a rake file and looks what tasks are available; | |
#Sort the capitals before the lowercase files, this means it will be sorted first; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# require 'pry' | |
class Crypto | |
def initialize(message) | |
@message = message | |
end | |
def cipher_message | |
plain_text = convert_plain_text | |
letter_segments = convert_segments(plain_text) | |
cipher(letter_segments) |