Skip to content

Instantly share code, notes, and snippets.

View GrahamSM's full-sized avatar

Graham Stirling-Moffet GrahamSM

View GitHub Profile
@GrahamSM
GrahamSM / gist:795cf6fb1f311d29308096cc3658cb21
Created May 1, 2016 18:18 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@GrahamSM
GrahamSM / Flight.rb
Last active May 2, 2016 20:31
Classical inheritance practice..
module Flight
def fly
if (self.can_fly?)
puts "I'm a #{self.class}! I'm flying!"
else
puts "Don't be stupid. #{self.class}'s can't fly."
end
end
end
There are two distinct cases that I will refer to in order to explain the behaviour of 'self' in ruby
First is within class 'instances'. When self is called within a class instance (instance of an object of said class), self is
in this case referring to that particular instance.
For example:
def my_method
p self
end
my_object = Object_Class.new
my_object.my_method
gem 'rspec'
gem 'pry'
gem 'byebug'
SELECT title, name, stock.isbn, stock,
CASE WHEN type = 'h' THEN 'Hardcover edition'
WHEN type = 'p' THEN 'Paperback edition'
ELSE 'Unkown'
END AS cover
FROM editions JOIN publishers ON (editions.publisher_id = publishers.id)
JOIN books ON (editions.book_id = books.id)
JOIN stock ON (stock.isbn = editions.isbn)
WHERE (publishers.name = 'Random House') AND (stock.stock > 0);
function arrayOfLight(x){
myArray = [];
for var(i = 0; i<=x; i++){
myArray[i] = i
}
return myArray;
}
<html>
<head>
<title>Ajax Example</title>
</head>
<body>
<section>
<h1>Recent Posts</h1>
<article>
<h2>Post 1</h2>
<p>This is post 1.</p>