Skip to content

Instantly share code, notes, and snippets.

Avatar

Jimmy Chen TechFounder

View GitHub Profile
@TechFounder
TechFounder / application.html.erb
Created Dec 17, 2018
Rails flash message using bootstrap styling - underneath navbar, full width
View application.html.erb
<%= render 'layouts/navbar' %>
# Put this flash message block between the navbar and the yield
<% flash.each do |name, msg| %>
<% unless flash_blacklist(name) %>
<%= content_tag(:div, class: flash_class(name)) do %>
<%= msg %>
<button type="button" class="close" data-dismiss="alert">×</button>
<% end %>
<% end %>
@TechFounder
TechFounder / _form.html.erb
Created Aug 7, 2018
Two method of using checkboxes on forms with Bootstrap 4
View _form.html.erb
# Store#performance
# This is the old way of doing checkbox collections.
# Note the hidden field tag to make sure that unchecked items are passed to the server
<fieldset class='form-group mx-sm-3'>
<legend class='pt-4'>Performance</legend>
<div class='row'>
<% hidden_field_tag 'store[performance_ids][]', nil %>
<% Performance.all.each do |performance| %>
<div class='col col-sm-6 pt-2'>
View rspec_matchers.rb
describe 'Expectation Matchers' do
describe 'equivalence matchers' do
it 'will match loose equality with #eq' do
a = "2 cats"
b = "2 cats"
expect(a).to eq(b)
expect(a).to be == b # synonym for #eq
@TechFounder
TechFounder / _settings.scss
Created Jun 26, 2017
Foundation 6 rails default css files - settings & overrides
View _settings.scss
// Foundation for Sites Settings
// -----------------------------
//
// Table of Contents:
//
// 1. Global
// 2. Breakpoints
// 3. The Grid
// 4. Base Typography
// 5. Typography Helpers
@TechFounder
TechFounder / style.css
Created Jun 27, 2016
Buddha bless your code to be bug free
View style.css
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
@TechFounder
TechFounder / addToAdvance.js
Last active May 11, 2016
SquareSpace javascript to remove day from date format
View addToAdvance.js
// you may need to first load jquery
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.js'></script>
$(document).ready(function () {
$('time span').remove();
});
// or if that doesn't work try this....
var monthNames = [ "January", "February", "March", "April", "May", "June",
@TechFounder
TechFounder / style.sass
Created Jan 28, 2016
Foundation 5 css class for minimizing row margins
View style.sass
.max-row-margin
width: 100%
margin-left: auto
margin-right: auto
max-width: initial
View comment
.
_
_._ _..._ .-', _.._(`))
'-. ` ' /-._.-' ',/
) \ '.
/ _ _ | \
| a a / |
\ .-. ;
'-('' ).-' ,' ;
'-; | .'
@TechFounder
TechFounder / font.sass
Created Jan 5, 2015
SASS mixin font sizes
View font.sass
$min-font-size: 10
$max-font-size: 50
@mixin font-sizes
@for $i from $min-font-size through $max-font-size
.font-#{$i}px
font-size: ($i / 16)em
@extend .font-normal
@include font-sizes
@TechFounder
TechFounder / javascript.js.coffee
Last active Aug 29, 2015
How to setup a fixed navbar using javascript when you have an extra header on top of it. Or, a fading navbar.
View javascript.js.coffee
# The basic idea here is that you set a num of pixels before triggering the css "fixed"
# which would freeze whatever you div attribute you set, in this case"nav".
# This is a simple way to do it but there's a library you can use to do the same thing.
# http://imakewebthings.com/jquery-waypoints/shortcuts/sticky-elements/
num = 250 #number of pixels before modifying styles
$(window).bind "scroll", ->
if $(window).scrollTop() > num
$("nav").addClass "fixed"
else
You can’t perform that action at this time.