Skip to content

Instantly share code, notes, and snippets.

View gogogarrett's full-sized avatar

Garrett Heinlen gogogarrett

  • Netflix
  • San Francisco, CA
View GitHub Profile
"Forget compatibility with Vi. Who cares.
set nocompatible
"Enable filetypes
filetype on
filetype plugin on
filetype indent on
syntax on
<div class="container">
<div class="row">
<div class="col4">
<p>Column 1</p>
</div>
<div class="col4">
<p>Column 2</p>
</div>
<div class="col4 last">
<p>Column 3</p>
@gogogarrett
gogogarrett / first_login.feature
Created June 7, 2012 13:09
LOST LEGEND - RPG Adventure Game
Feature: First Login
In order to login the first time
As a player
I want to be able to select my vocation in order to play the game
Scenario: Start playing the game
Given I am on the root path
And I click on sign up
And I fill in the form and select my vocation
Then I should be directed to the application
$("#name").keyup(function() {
var s = $(this).val(),
url = "<%= recipient_search_path %>";
if ( s.length > 2 || s.length == 0 ) {
$.post( url, { s: s }, function( data ) {
if ( s.length == 0 ) {
$("#recipients").find('option').show();
}
else {
$("#recipients").find('option').hide();

Sometimes we need to make post request to controller actions to do logic that we need to return back to the views. This can easily be handled with the help of jQuery and a little understanding of how rails handles request.

This may not be the best scenario for this to be applied, but I'm just giving grounds for this example.

Let's say for example we have this code:

list_blogs.html.erb

<a href="#" id="save"> Save Changes </a>
class Comment < ActiveRecord::Base
def self.build_from object, user_id, comment
# method_stuff_here
end
class << self
def build_from object, user_id, comment
# method_stuff_here
end
[mcf]$ cat ~/.bashrc
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@gogogarrett
gogogarrett / core_topic.rb
Last active December 12, 2015 09:29
Harness PGSearch and return back a specific output grouped by core topics to fulfill my searching needs!
class << self
# This will loop through each topic and create an array of objects that are
# found within a specific topic.
#
# Example: CoreTopic.find_by_topic(pg_search_results_array)
# Output: [
# { topic: "teamwork", results: [ob1, obj2, obj3] }
# { topic: "respect", results: [ob1, obj2, obj3] }
# ]
def find_by_topics(results)
<% menu = Refinery::Menu.new(Refinery::Page.fast_menu.where(:parent_id => @page.root.id)) -%>
<%= render :partial => "refinery/menu", :locals => {
:roots => menu
} %>