Skip to content

Instantly share code, notes, and snippets.

View TechFounder's full-sized avatar

Jimmy Chen TechFounder

View GitHub Profile
@TechFounder
TechFounder / application.html.erb
Created December 17, 2018 16:19
Rails flash message using bootstrap styling - underneath navbar, full width
<%= 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 August 7, 2018 14:48
Two method of using checkboxes on forms with Bootstrap 4
# 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'>
@TechFounder
TechFounder / rspec_matchers.rb
Created July 2, 2018 17:28
RSpec 3 Matchers
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 June 26, 2017 13:30
Foundation 6 rails default css files - settings & overrides
// 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 June 27, 2016 03:05
Buddha bless your code to be bug free
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
@TechFounder
TechFounder / addToAdvance.js
Last active May 11, 2016 16:05
SquareSpace javascript to remove day from date format
// 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 January 28, 2016 19:26
Foundation 5 css class for minimizing row margins
.max-row-margin
width: 100%
margin-left: auto
margin-right: auto
max-width: initial
@TechFounder
TechFounder / comment
Created January 7, 2015 19:22
Safety Pig
.
_
_._ _..._ .-', _.._(`))
'-. ` ' /-._.-' ',/
) \ '.
/ _ _ | \
| a a / |
\ .-. ;
'-('' ).-' ,' ;
'-; | .'
@TechFounder
TechFounder / font.sass
Created January 5, 2015 22:50
SASS mixin font sizes
$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 August 29, 2015 14:07
How to setup a fixed navbar using javascript when you have an extra header on top of it. Or, a fading navbar.
# 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