Skip to content

Instantly share code, notes, and snippets.

@mathildathompson
Last active August 29, 2015 14:01
Show Gist options
  • Save mathildathompson/ebf0984c984c2f7e35e6 to your computer and use it in GitHub Desktop.
Save mathildathompson/ebf0984c984c2f7e35e6 to your computer and use it in GitHub Desktop.
#Takes all commands written in text and converts into magic numbers, compiles into executable byte code which is Ruby specific;
#Converts english language into byte code, executes the byte code;
#The byte code is the sameo on every system (if you were running on mac or nintendo);
#To make it work it has to call the operating system;
#Opaerting system, library that knows how to open and close files, talk to the network, do mathemtatical stuff #When you intall operating system comes which a bunch of libraries;
#Ruby talks to the operating system which talks to the libraries;
#Underneath the operating system we have to BIOS (basic input output system). It knows how to talk with the hardward, what is the resolution of the screen, is a keyboard attached. The bios is read only;
#Underneath the bios was have the hardware. This is the horrible stuff to do with voltage etc.
#When inventing machine decide what is a 1 and what is a 0;
#Operating system filled with computer science;
##ALGORITHMS
#Describe the efficiency of an algorithm using bigO notation;
O(N) #Here if we double n the whole process will take twice as long!;
O(N^2) #Exponential, as N increases the amount of time increases by the square of that number;
##A hash is setup internally so that you can looksomething up in that straight away;
##BINARY SEARCH
#If you are looking through a phone book, open it half way along and work out which half you need to continue to search through;
#You can search for things in close to constant time;
#Binary search needs to be in order;
N = number of items in the sequence;
log 2 N steps #Not double, but greater than linear;
##RECURSION
#Functional Javascript;
#Regular Expression;
#If you push too many things onto the stack, the stack level can go too deep;
#2195 times into the stack before it runs out of memory;
var sayHi = function(){ #Applied recursion instead of using setInterval; ZETAFLEET;
window.setTimeout(function(){
console.log('Hi')
sayHi();
}, 1000);
}
sayHi();
def factorial_i(n)
product = 1
while n > 1
product = product * n
n -= 1
end
product
end
factorial_i(7)
##FIBONACCI
def fibaonacci_i(n)
a = 1
fib = b = 1
while (n > 2)
fib = a + b
a, b = b, fib #Ruby lets you use parrallel assignment;
n -= 1
end
fib
end
fibonacci(5)
def fibonacci_r(n)
if n == 1 || n == 2
1
else
fibonacci_r(n - 1) + fibonacci_r(n - 2)
end
end
fibonacci(5)
#FRACTAL
##JQUERY2
#Does not work in IE7, therfore you need to use 1.11 and not 2 if you need to support IE8;
##RESOURCES
#The Little Schema;
#yayQuery.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment