Skip to content

Instantly share code, notes, and snippets.

@jenreiher
jenreiher / fizzbuzz.rb
Created June 6, 2018 03:25
Our fizzbuzz
fizz = "fizz"
buzz = "buzz"
data = (1..100)
data.each do |number|
if number % 3 == 0 and number % 5 == 0
p fizz + buzz
elsif number % 5 == 0
p buzz
elsif number % 3 == 0
@jenreiher
jenreiher / 1.rb
Created November 16, 2017 04:04
Building towards complex data in Ruby
# Let's make a variable!
# This will let us store some information so we can refer to it later
favourite_harry_potter_character = "Hermione Granger"
# Now that we've save it, let's actually "call" or refer to that same value again
favourite_harry_potter_character
# This would output Hermione Granger
# Ok so... say we change our minds, say that now we have been corrupted by the Slytherin...
@jenreiher
jenreiher / pirate.html
Created November 9, 2017 03:11
Pirate HTML (no css)
<head>
</head>
<body>
<div id="info-container">
<h1>Yar Pirate Ipsum</h1>
<img src="https://static.esea.net/global/images/users/1062706.1485900665.png" />
<p>
Prow scuttle parrel provost Sail ho shrouds spirits boom mizzenmast yardarm. Pinnace holystone mizzenmast quarter crow's nest nipperkin grog yardarm hempen halter furl. Swab barque interloper chantey doubloon starboard grog black jack gangway rutters.
</p>
@jenreiher
jenreiher / app.css
Created September 18, 2017 20:19
Polly wants some CSS
body {
font-family: cursive;
padding: 25px;
font-size: 16px;
}
p {
color: purple;
}
@jenreiher
jenreiher / vocab.md
Last active September 12, 2017 02:36
LHL Part Time Course Vocab Sept-Oct 2017

Word we learned so far:

  • Stack: the different technologies and languages to a working web application. Different companies have different "stacks".
  • Git: a type of version control that allows us to track changes and go back to previous versions.
  • Boilerplate: a basic set up to work with for any particular web app framework (e.g. Sinatra).
@jenreiher
jenreiher / index.html
Created June 20, 2017 01:53
Media Queries
<link rel="stylesheet" href="style.css">
<div class="demo-container">
<div class="demo-header">
<h1 class="demo-title">I didn't even know Smarties made a cereal</h1>
<div class="demo-header-image">
<img src="https://vignette2.wikia.nocookie.net/theitcrowd/images/a/a9/Moss_with_big_glasses.png/revision/latest?cb=20100903162250">
</div>
</div>
<div class="demo-body">
@jenreiher
jenreiher / actions.rb
Created June 12, 2017 23:26
Sessions in Sinatra! Woot woot
helpers do
def current_user
User.find_by(id: session[:user_id])
end
end
post '/login' do
username = params[:username]
password = params[:password]
@jenreiher
jenreiher / Course.rb
Last active June 6, 2017 02:07
W3D1 Active Record Associations Example
class Course < ActiveRecord::Base
has_many :students
# oh look! a handy dandy instance method
def count_students(id)
@students = Student.where(course_id: id))
end
end
// All your imports go at the top! This includes any subcomponents or helpers you have npm installed
import React from 'react';
// Generally I find you use ImportName when using the default export,
// and {ImportName} when you are importing an exported function [or more than one] from a file/folder
import SubComponent from '../components/SubComponent'
// here is the basic setup before you start filling it with code
class MyComponent extends React.Component {
// the constructor is optional, and generally only included
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<form>
<div>
<label for="name">Place your bet between $5 and $10:</label>
<select id="bet" name="bet">
<option value="10">$10</option>
<option value="9">$9</option>