Skip to content

Instantly share code, notes, and snippets.

View TechFounder's full-sized avatar

Jimmy Chen TechFounder

View GitHub Profile
@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 / 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 / configfolder.yml
Created June 1, 2014 16:56
secret - Figaro Gem vs Rails 4.1 These two files shows the difference in configuration between the two methods of keeping environment variables secret.
# figaro gem
# config/application.yml
stripe_publishable_key: pk_test_TLr0qqdKhm0yX1bZtKC4kFAC
stripe_secret_key: sk_test_Qbppb2nkFEzPoquOdBym0JL2
# rails 4.1
# config/secrets.yml
stripe_publishable_key: pk_test_TLr0qqdKhm0yX1bZtKC4kFAC
stripe_secret_key: sk_test_Qbppb2nkFEzPoquOdBym0JL2
@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 / 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 / simple_form_bootstrap3.rb
Last active January 2, 2016 13:09
Use this configuration in your initializer for simple_form if you're using bootstrap 3. https://github.com/gregbell/active_admin/issues/2703
SimpleForm.setup do |config|
config.input_class = 'form-control'
config.boolean_style = :nested
config.wrappers :bootstrap3, tag: 'div', class: 'form-group', error_class: 'has-error',
defaults: { input_html: { class: 'default_class' } } do |b|
b.use :html5
@TechFounder
TechFounder / form.htm.erb
Created January 1, 2014 16:01
How to add value to input area in rails form.
<div class="form-inputs">
<%= f.input :title, :input_html => { :value => "This is title field value." } %>
<%= f.input :body, :input_html => { :value => "This is body field value." } %>
</div>
or
<div class="form-inputs">
<%= f.input :title, input_html: { :value => "This is title field value." } %>
<%= f.input :body, input_html: { :value => "This is body field value." } %>