Skip to content

Instantly share code, notes, and snippets.

Avatar

Jesse Waites piratebroadcast

View GitHub Profile
@piratebroadcast
piratebroadcast / gist:ff057097328b823251b3976117404934
Created Oct 26, 2017
Link To External Page in React Router
View gist:ff057097328b823251b3976117404934
<BrowserRouter>
<div>
<Match exactly pattern="/google" component={() => window.location = 'http://google.com'} />
<Match pattern="/store/:storeId" component={App} />
<Miss component={NotFound} />
</div>
</BrowserRouter>
View gist:fa56eb3fd9d576f0f1211b2098952b99
def create
if @thing.save
redirect_to thing_form_path(@thing), notice: "You saved the thing!"
else
flash[:error] = @thing.errors.full_messages.to_sentence
render :new
end
end
View ReportCardMailer.rb
class ReportCardMailer < ActionMailer
def report(user)
@user = user
@report_card = user.report_cards.last
options = {
to: @user.email,
from: "admin@yoursite.com",
subject: "Your Report Card for "@report_card.report_start_time.strftime("%b %d, %Y")" to
@piratebroadcast
piratebroadcast / gist:e5ccf9ab8ac7c71f45cf1ca6064d8091
Created Apr 22, 2016
Rails Flash Messages for Zurb Foundation 5+
View gist:e5ccf9ab8ac7c71f45cf1ca6064d8091
<!-- Rails flash messages styled for Zurb Foundation. -->
<!-- Activate with flash.message = "X", flash.alert = "Y" -->
<% flash.each do |name, msg| %>
<% if msg.is_a?(String) %>
<div data-alert style="text-align" class="alert-box <%= name.to_s == 'notice' ? 'success' : 'alert' %>">
<%= content_tag :div, msg %>
<a href="#" class="close">&times;</a>
</div>
<% end %>
<% end %>
View metadata
<head>
<!-- other stuff in your site header like javascript or whatever above here -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@your_twitter_handle">
<meta name="twitter:creator" content="@your_twitter_handle">
<!-- hardcoding an image here so I don't have to worry about attaching an image to each blog post in the future -->
View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
View user_stories.txt
=========================================================
I am a subscriber
I want to view full articles
So that I can get convenient access to the news
---------------------------------------------------------
Subscriber Acceptance Requirements:
-Subscriber logs in system recognizes him as a subscriber allows full access to articles
=========================================================
I am a non-subscriber
I want to preview the article and be able to subscribe
View User Story Launch Academy assignment
User Stories HW
"As a ______, I want to _____ so I can _____."
As any visitor, I want to see orderly article layout so I can decide what to read.
As a premium subscriber, I want to easily see the premium so I can feel like I am getting my moneys worth.
As a premium subscriber, I want to see fewer ads so I can concentrate on and enjoy the content I paid for.
As a free visitor, I want to see prominent "membership" opportunities so I can become a paying member if I decide.
View rack.rb
chris@luna ~ (master*) $ telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /?name=Chris HTTP/1.0
HTTP/1.1 200 OK
Content-Type: text/html
Server: WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10)
Date: Sat, 13 Apr 2013 00:07:11 GMT
You can’t perform that action at this time.