Skip to content

Instantly share code, notes, and snippets.

View JaysonMandani's full-sized avatar
🚀
Build. Launch. Repeat.

Jayson Mandani JaysonMandani

🚀
Build. Launch. Repeat.
View GitHub Profile
@JaysonMandani
JaysonMandani / index.haml
Created January 3, 2018 18:34
sample view
- content_for :head do
= stylesheet_link_tag 'products_page.css'
= stylesheet_link_tag 'product_page.css'
%main.products-page
.row
- if params[:category_type].present?
%ul.breadcrumbs.column
%li
%a{:href => "/"} Home
%li
@JaysonMandani
JaysonMandani / products_controller.rb
Created January 3, 2018 18:31
sample controller
class ProductsController < ApplicationController
def index
products = Product.active.includes(:variants).paginate(page: params[:page], per_page: 15).order('created_at ASC')
if params[:keyword].present?
@products = Product.standard_search(params[:keyword]).paginate(page: params[:page], per_page: 15).order('created_at ASC')
else
product_types = nil
if params[:product_type_id].present? && product_type = ProductType.find_by_id(params[:product_type_id])
@JaysonMandani
JaysonMandani / product.rb
Created January 3, 2018 18:29
sample model
# == Schema Information
#
# Table name: products
#
# id :integer(4) not null, primary key
# name :string(255) not null
# description :text
# product_keywords :text
# product_type_id :integer(4) not null
# prototype_id :integer(4)
export const addTodo = text => ({ type: types.ADD_TODO, text })
export const deleteTodo = id => ({ type: types.DELETE_TODO, id })
export const editTodo = (id, text) => ({ type: types.EDIT_TODO, id, text })
export const completeTodo = id => ({ type: types.COMPLETE_TODO, id })
export const completeAll = () => ({ type: types.COMPLETE_ALL })
export const clearCompleted = () => ({ type: types.CLEAR_COMPLETED })
export default function todos(state = initialState, action) {
switch (action.type) {
case ADD_TODO:
return [
...state,
{
id: state.reduce((maxId, todo) => Math.max(todo.id, maxId), -1) + 1,
completed: false,
text: action.text
}
@JaysonMandani
JaysonMandani / css-media-queries-cheat-sheet.css
Created October 23, 2017 07:23 — forked from bartholomej/css-media-queries-cheat-sheet.css
CSS Media Query Cheat Sheet (with Foundation)
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }
@JaysonMandani
JaysonMandani / devise_authentication_api.rb
Created November 23, 2016 06:28 — forked from skozz/devise_authentication_api.rb
Authenticate your API with Devise gem, token by header. Ruby on Rails 4. Read the comments.
#Session controller provides a token
#/controllers/api/sessions_controller.rb
class Api::SessionsController < Devise::SessionsController
before_filter :authenticate_user!, :except => [:create]
before_filter :ensure_params_exist, :except => [:destroy]
respond_to :json
def create
resource = User.find_for_database_authentication(:email => params[:user_login][:email])
return invalid_login_attempt unless resource
@JaysonMandani
JaysonMandani / xcode-build-bump.sh
Created July 12, 2016 02:16 — forked from sekati/xcode-build-bump.sh
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@JaysonMandani
JaysonMandani / rspec_model_testing_template.rb
Created March 10, 2016 21:29 — forked from PWSdelta/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname