Skip to content

Instantly share code, notes, and snippets.

<head>
<title>meteor_servercall</title>
</head>
<body>
{{> simple}}
{{> passData}}
</body>
<template name="simple">
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
@LukaHuang
LukaHuang / application_helper.rb
Created September 23, 2014 16:11
notice_helper_rails101
module ApplicationHelper
def notice_message
alert_types = { :notice => :success, :alert => :danger }
close_button_options = { :class => "close", "data-dismiss" => "alert", "aria-hidden" => true }
close_button = content_tag(:button, "×", close_button_options)
alerts = flash.map do |type, message|
alert_content = close_button + message
alert_type = alert_types[type.to_sym] || type
alert_class = "alert alert-#{alert_type} alert-dismissable"
@LukaHuang
LukaHuang / _footer.html.erb
Created October 20, 2014 11:43
bs3-footer
def require_user
if !logged_in?
flash[:error] = "You must log in to do that"
redirect_to root_path
end
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<nav>
<div class="container">
<ul class="navlist">
@LukaHuang
LukaHuang / normalize.css
Created January 24, 2015 07:00
normalize.css
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined in IE 8/9.
*/
@LukaHuang
LukaHuang / dev.rake
Created September 5, 2015 15:32
dev fakeup
namespace :dev do
desc "Generate fake data"
task fakeup: ['db:schema:load', :environment] do
20.times do |i|
Product.create(
name: "product no.#{i}", description: "description no.#{i}",
price: (rand(10) + 1) * 50, stock: rand(91) + 10
)
end
cart = Cart.create
@LukaHuang
LukaHuang / rails http status codes
Created October 10, 2015 11:03 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@LukaHuang
LukaHuang / dev.rake
Last active October 31, 2015 09:26
generate fake data
namespace :dev do
desc "Generate fake data"
task fakeup: ['db:schema:load', :environment] do
20.times do |i|
Product.create(
name: "product no.#{i}", description: "description no.#{i}",
price: (rand(10) + 1) * 50, stock: rand(91) + 10
)
end
cart = Cart.create