Skip to content

Instantly share code, notes, and snippets.

View nixsiow's full-sized avatar

Nix Siow nixsiow

View GitHub Profile
#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;

Crypto Square

One classic method for composing secret messages is called a square code.

The spaces and punctuation are removed from the English text and the characters are written into a square (or rectangle) and the entire message is downcased. For example, the sentence "If man was meant to stay on the ground god would have given us roots" is 54 characters long, so it is written into a rectangle with 7 rows and 8 columns.

$(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,

Robot Name

When robots come off the factory floor, they have no name.

The first time you boot them up, a random name is generated, such as RX837 or BC811.

In other words, if I say:

puts "Robot 1: "
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;
Ruby Quickstart for Refugees:
--
# is a comment.
You don't need semicolons.
Ruby aims to be elegant and readable, so punctuation and boilerplate are
minimal.
--
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
# Hexadecimal
On the web we use hexadecimal to represent colors, i.e. green: 008000, teal: 008080, navy: 000080).
Write a program that will convert a hexadecimal number, represented as a string (i.e. "10af8c"), to it's decimal equivalent using first principles (i.e. no, you may not use built-in ruby libraries or gems to accomplish the conversion).
The program should consider strings specifying an invalid hexadecimal as the value 0.
##DEPLOYING TO HEROKU
#Create an account on Heroku
https://www.heroku.com
#Download Heroku Toolbelt (a client for generating and creating heroku apps);
https://toolbelt.heroku.com/
heroku login #in the command line #It should generate SSH keys (we may have to do this manually);
#Gem list and check that you have the gem bundler; (You can do gem list | grep bundler);
#If you do not have it then install it:
gem install bundler #We have already done this;
##RAILS
#The router works out which controller to talk to;
#The controller talks to the models, the models talk to the views;
#One file shows you all of the different routes in your programme;
##To get into you bash profile
subl ~/.bash_profile #Goes into your bash_terminal;
echo $PATH #Shows your path;