Skip to content

Instantly share code, notes, and snippets.

View lisaychuang's full-sized avatar

Lisa Huang-North lisaychuang

View GitHub Profile
@lisaychuang
lisaychuang / index.html
Last active May 29, 2017 15:12
AMP Corgi Demo
<!doctype html>
<html amp>
<head>
<meta charset="utf-8">
<link rel="canonical" href="self.html" />
<link href="https://fonts.googleapis.com/css?family=Crimson+Text|Fredoka+One" rel="stylesheet">
<meta name="viewport" content="width=device-width,minimum-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style
@lisaychuang
lisaychuang / new.erb
Created July 26, 2017 17:33
Sinatra Course Management: new course page
<div class="mui-row">
<div class="mui-col-md-12">
<h1>Create a new course</h1>
<form method="post" action="/courses" class="mui-form">
<legend>Course name</legend>
<div class="mui-textfield">
<input type="text" name="name" id="name" required/>
</div>
<legend>Course icon</legend>
@lisaychuang
lisaychuang / layout.erb
Last active July 26, 2017 17:44
Sinatra Course Management: layout.erb
<!DOCTYPE html>
<html>
<head>
<title>📚 Online Course Management</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//cdn.muicss.com/mui-0.9.18/css/mui.min.css" rel="stylesheet" type="text/css" />
<script src="//cdn.muicss.com/mui-0.9.18/js/mui.min.js"></script>
<style>
@lisaychuang
lisaychuang / layout-menubar.erb
Created August 6, 2017 18:37
Sinatra Course Management: layout.erb menu bar section
<%# SHOW Dropdown menu only when user is logged in %>
<div class="mui-col-md-2">
<% if logged_in? %>
<div class="mui-dropdown">
<button class="mui-btn mui-btn--raised" data-mui-toggle="dropdown">
<span class="mui-caret"></span>
</button>
<ul class="mui-dropdown__menu mui-dropdown__menu--right">
@lisaychuang
lisaychuang / product.rb
Created August 8, 2018 05:55
Rails-riflepaper Product Model
class Product < ActiveRecord::Base
belongs_to :wishlist
belongs_to :category
# Validations
validates :name, :price, :url, :image_link, presence: true
validates :url, uniqueness: true
validates :name, length: {minimum: 2}
#Scope methods
@lisaychuang
lisaychuang / scraper.rb
Created August 8, 2018 06:05
rails-riflepaper web scraper
require 'nokogiri'
require 'open-uri'
require 'pry'
class Scraper
def get_page(url_str)
html = open(url_str)
doc = Nokogiri::HTML(html)
doc
@lisaychuang
lisaychuang / router.rb
Created August 8, 2018 06:59
rails-riflepaper router
Rails.application.routes.draw do
post '/wishlists/:id/toggle_product' => 'wishlists#toggle_product', as: :toggle_wishlist_product
resources :users do
resources :wishlists
end
resources :sessions
resources :products do
@lisaychuang
lisaychuang / show.html.erb
Created September 8, 2018 23:27
Rails-riflepaper Product Show Page
<!-- Button to show Next Product using AJAX GET request-->
<button class="js-next" data-id="<%= @product.id %>">Next product</button>
<br>
<!-- Product square -->
<div class="product-square">
<h1 class="name"><%= @product.name%></h1>
<p class="category">Category: <%= @product.category.name%></p>
<p class="price">Price: <%= "#{number_to_currency(@product.price)}" %></p>
@lisaychuang
lisaychuang / show.html.erb
Created September 8, 2018 23:41
Rails-riflepaper Wishlist Show Page
<!-- Wishlist square -->
<div class="wishlist-info">
<h1>Wishlist: <%= @wishlist.name%></h1>
<p>Created on: <%= @wishlist.date_created%></p>
<p>Budget: <%= number_to_currency(@wishlist.budget)%></p>
<p>Notes: <%= @wishlist.notes%></p>
<% if display_edit_delete_link %>
<%= link_to("Edit wishlist", edit_user_wishlist_path(@user, @wishlist)) %><br><br>
@lisaychuang
lisaychuang / _newForm.html.erb
Created September 9, 2018 02:57
Rails-riflepaper Wishlist New Page
<h1>Create a new wishlist</h1>
<!-- Form for creating a new Wishlist -->
<%= form_for([user, wishlist]) do |f|%>
<p>
<%= f.label :name %>
<%= f.text_field :name %><br>
<%= f.label :budget %>
<%= f.number_field :budget, value: number_to_currency(f.object.budget.to_f, delimiter: '', unit: ''), step: :any %><br>