Skip to content

Instantly share code, notes, and snippets.

@szankowski
szankowski / contact.rb
Last active August 29, 2015 14:24
Contact List SQL
require 'pg'
class Contact
attr_reader :id
attr_accessor :firstname, :lastname, :email
def initialize(firstname, lastname, email, id = nil)
@firstname = firstname
@lastname = lastname
@email = email
@szankowski
szankowski / ReadMe.txt
Last active August 29, 2015 14:24
SQL SELECT
123
@szankowski
szankowski / ex02.sql
Last active August 29, 2015 14:24
Learn SQL The "Hard" Way (Tutorial)
CREATE TABLE person (
id INTEGER PRIMARY KEY,
first_name TEXT,
last_name TEXT,
age INTEGER
);
CREATE TABLE pet (
id INTEGER PRIMARY KEY,
name TEXT,
@szankowski
szankowski / game.rb
Last active August 29, 2015 14:23
Game V3 with exeptions
class Game
attr_accessor :game_over
attr_reader :player_turn
def initialize
@game_over = false
@player_turn = 1
end
def turn_changer
return @player_turn == 1 ? @player_turn = 2 : @player_turn = 1
end
@szankowski
szankowski / animals.rb
Last active August 29, 2015 14:23
Classical Inheritence (Mini Exercise)
class Animal
attr_accessor :name, :num_legs, :warm_blood
def initialize(name, num_legs, warm_blood)
@name = name
@num_legs = num_legs
@warm_blood = warm_blood
end
@szankowski
szankowski / exercice_ok.rb
Last active August 29, 2015 14:23
File io Exercise
require 'open-uri'
require "rubygems"
require "rest-client"
#### EXERCICE 1
# assign the url source to a var
url = "http://ruby.bastardsbook.com/files/fundamentals/hamlet.txt"
# seting a var with the file name you want to creat
local_fname = "hamlet.txt"
# using File.open in "w"rite mode to write a hamlet.txt file
@szankowski
szankowski / game.rb
Last active August 29, 2015 14:23
game guess math v2
class Game
attr_accessor :game_over, :player_turn
def initialize
@game_over = false
@player_turn = 1
end
def turn_changer
return @player_turn == 1 ? @player_turn = 2 : @player_turn = 1
end
# def game_over(game)

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
@szankowski
szankowski / gist:12ea1946ef4bd95ff561
Last active August 29, 2015 14:23
counting_letters
We couldn’t find that file to show.
@szankowski
szankowski / gist:c0b6e3dcd1e1f938e50e
Created June 24, 2015 02:14
coding_your_code (quoter)
def quote_maker(dimension,colours)
price = dimension * dimension * 15.to_f
if colours <= 2
colour_cost = 10 * colours
price = price + colour_cost
elsif colours > 2
colour_cost = 15 * colours
price = price + colour_cost
end