Skip to content

Instantly share code, notes, and snippets.

View mathildathompson's full-sized avatar

mathilda thompson mathildathompson

View GitHub Profile

#Javascript

Scope

####Introduction When you declare a variable for the first time, you must use the var keyword, but when you update the value within the variable, you don't use the var keybord.

var pocket = ['phone', 'kindle'];
pocket = ['oysterCard', 'keys'];
@mathildathompson
mathildathompson / 0_reuse_code.js
Created July 22, 2014 14:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
npm install -g coffee-script //Globally install node package;
npm install coffee-script //Install locally in the folder; //Like locally installing a gem;
node node_modules/coffee-script/bin/coffee
node_modules/coffee-script/bin/coffee hello.coffee
//Need to compile to Javascript for the browser to read;

Ruby 2.1.0 #major version, minor version and the patch level; Rails 4.1.0

##Semantic versioning Left most number is the version number, this is the particular version, brand new version, if you wanna use with old code you need to read documentation; Rails 4.2.0 Rails 4.3.5 #Stuff that has the same major version number is all compatible with each other;

##Tags Let you put a specific name to a particular version;

def each(&block)
node = @head
while node
block.class(node.value)
end
end
#A minix a way of adding extra data to the class without having to use inheritance;
#You can only inherit from one class, a way to get around this is to created mixins;
//nodejs.org
//CANARY is the next version of CHROME;
//CHROMIUM -> CANARY -> CHROME:
node //Type this into terminal;
//Node is now running on the server on ts own;
0.1 + 0.2
console.log('hi');
//It is so fast as it has not features out of the box;
//Bare bones, all driven by callBacks;Uses those same ideas over and over again;
var DNAStringFactory = function(string){
var DNA = {
string: string,
count: function(letter){
if (!_.contains(['A', 'G', 'C', 'T', 'U'], letter)){
return alert('This is not valid!');
}
var result = _.filter(this.string, function(nucleotide){
return nucleotide == letter;
$(document).ready(function(){
if(! window.DeviceOrientationEvent){
return;
}
$(window).on('deviceorientation', function(){
console.log('device-reorientated');
})
console.log('everything is fine');
});
#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.
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(messageString){
this.message = messageString;
}