Skip to content

Instantly share code, notes, and snippets.

View arthur-littm's full-sized avatar

Arthur Littmann arthur-littm

  • Butternut Box
  • London
View GitHub Profile
<div class="cards-container">
<div class="card">
<div class="card-image" style="background-image: url(<%= image_path("background.jpg") %>);">
</div>
<div class="card-info">
<p>Description</p>
<span>Technologies:</span>
<ul>
<li>Item</li>
<li>Item</li>
@arthur-littm
arthur-littm / form_validation.js
Last active April 12, 2017 16:20
Form validation livecode
// Your validation code will go in there.
// Write your validation functions, and bind events
// in a jQuery DOM ready callback
$(document).ready(function() {
var events = "blur keyup"
$(".form-control").on(events, function() {
var value = $(this).val();
if (value === "") {
$(this).parent().removeClass('has-success').addClass('has-error');
age = 23
# *Assign* the value 23 to my variable `age`
puts "a year as passed"
# *Re-assigning* the value of the variable `age`
age = age + 1
# age += 1
# Interpolating the variable `age` inside a string
counter = 1
#generate random number between 1-100
price = rand(1..2)
puts "guess a number chump"
pick = gets.chomp.to_i
p pick
until pick == price
if pick < price
puts "A little higher! Try again"
students = [ "Peter", "Mary", "George", "Emma" ]
student_ages = [ 24 , 25 , 22 , 20 ]
# - Peter is X years old
students.each_with_index do |name, index|
age = student_ages[index]
puts "#{name} is #{age} years old"
end
text = open('article.txt').read
#create hash
histogram = {}
words = text.split
special_chars = (" ".."@").to_a
special_chars << ":"
# car.rb -> lower_snake_case
class Car # UpperCamelCase
attr_reader :engine_started, :brand
attr_accessor :colour
def initialize(colour, brand = "Mini") # constructor
@colour = colour
@engine_started = false
@brand = brand
class FacebookUser
# DATA (instance variables)
attr_reader :email, :friends, :photos
attr_accessor :first_name, :last_name
def initialize(email, password) # constructor
@email = email
@password = password
@first_name = ""
@last_name = ""
class Chef
attr_reader :name, :restaurant
def initialize(name, restaurant)
@name = name # String
@restaurant = restaurant # Restaurant
end
end
class Patient
attr_accessor :room, :id
attr_reader :name, :cured
def initialize(attributes = {})
@id = attributes[:id]
@room = attributes[:room] # Instance of Room
@name = attributes[:name]
@cured = attributes[:cured] || false
end