Skip to content

Instantly share code, notes, and snippets.

View keeperofthenecklace's full-sized avatar

Albert McKeever keeperofthenecklace

  • New Jersey, U.S.A
View GitHub Profile
@keeperofthenecklace
keeperofthenecklace / search_controller.rb
Last active August 29, 2015 14:25
This is based of ElasticSearch.
class SearchController < ApplicationController
before_action :set_search_option, only: [:index]
# Query the product model and return all indexed items.
def index
@product_results = ProductsIndex.aggregations(search_aggregations)
apply_filters(@search_options[:search_with]).each { |filter| @product_results = @product_results.merge(filter) }
# Apply any facet filters already selected
if @search_term.present?
@keeperofthenecklace
keeperofthenecklace / index.html.erb
Created July 23, 2015 17:43
Displays all products.
<h4><%= @product[0].quote.category.name.titleize if @product.present? %> Products</h4>
<% if @product.present? %>
<%= render partial: '/products/listings', locals: { product: @product } %>
<% else %>
<p>The are no agape love quotes</p>
<%= render partial: '/products/no_product' %>
<% end %>
DASH
------
:Dash[!]
:Dash printf
:Dash setTimeout javascript
:Dash!
:Dash! func #Will search for 'func' in all docsets.
:DashKeywords
:DashKeywords backbone underscore javascript
@keeperofthenecklace
keeperofthenecklace / Mnitest
Created January 14, 2014 16:52
Running minutest
rake test TEST=test/models/admin_ability_test.rb
CTRL Ww moves you from window to window (
CTRL WT moves current window into a tab
t (While in nerdtree) opens the file in a tab.
gt Goes to next tab.
gT Goes to previous tab.
\n Toggles the NerdTree on or off.
Command T - find in project.
new_record?
any?
kind_of?
include?
nil?
blank?
clear?
empty?
ActiveRecord
-----------
SERIALIZED ATTRIBUTE
$ rails c --sandbox or rails c development
#create class method
$ user = User.create( name" "albert", email: "kotn_ep1@hotmail.com" )
#new class method
@keeperofthenecklace
keeperofthenecklace / IRB - Useful commands
Created August 24, 2012 11:21
IRB - Useful commands
$ IRB ****Let you into Ruby Interpreter
1.9.3-p194 :088 > use TAB key to autocomplete.
1.9.3-p194 :089 > help
Enter the method name you want to look up.
You can use tab to autocomplete.
Enter a blank line to exit.
@keeperofthenecklace
keeperofthenecklace / Loading ruby script in IRB
Created August 23, 2012 17:36
Loading ruby script in IRB
cd into directory of the Ruby.rb file...
it-macbook-albert:karoake albertmckeever$ IRB
1.9.3-p194 :001 > load 'song.rb'
=> true
@keeperofthenecklace
keeperofthenecklace / Command line Shortcut
Created August 22, 2012 16:58
Command line Shortcut
Esc shft + b - moves cursor(c) BACK to begin of a text. eg. (c)albert (c)mckeever (c)help
Esc shft+ f moves cursor(c) FORWARD to begin of a text. eg. (c)albert (c)mckeever (c)help
shft + cmd - selects all
Ctrl+A and Ctrl+E - home and end
Ctrl+U: This clears the entire line so you can type in a completely new command.
Ctrl+K: This deletes the line from the position of the cursor to the end of the line.
Ctrl+W: This deletes the word before the cursor only.
Ctrl+R: This lets you search your command history for something specific.
Tab: autocomplete