Skip to content

Instantly share code, notes, and snippets.


Albert McKeever keeperofthenecklace

View GitHub Profile
keeperofthenecklace / search_controller.rb
Last active Aug 29, 2015
This is based of ElasticSearch.
View search_controller.rb
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?
View index.html.erb
<h4><%= @product[0] 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 %>
View gist:af1f16f20947612577d3
:Dash printf
:Dash setTimeout javascript
:Dash! func #Will search for 'func' in all docsets.
:DashKeywords backbone underscore javascript
View Mnitest
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.
View gist:3729666
View ActiveRecord
$ rails c --sandbox or rails c development
#create class method
$ user = User.create( name" "albert", email: "" )
#new class method
View 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.
View 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
View 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