Skip to content

Instantly share code, notes, and snippets.

View axsuul's full-sized avatar

James Hu axsuul

View GitHub Profile
# this is evaluated as: add_index(:charts, {:name => :date}, {:unique => true})
add_index :charts, {:name, :date}, :unique => true
# this is evaluated as: add_index(:charts, [:name, :date], {:unique => true})
add_index :charts, [:name, :date], :unique => true
<% zombies.each do |zombie| %>
<li><%= zombie.name %></li>
<% end %>
<ul>
<% zombies.each do |zombie| %>
<li>
<%= zombie.name %>
<% if zombie.tweets.count > 1 %>
SMART ZOMBIE
<% end %>
</li>
<% end %>
</ul>
@axsuul
axsuul / database.yml
Created September 17, 2011 20:12 — forked from anonymous/exec
database.yml
development:
adapter: mysql
host: localhost
database: depot_development
username: root
password: root
@axsuul
axsuul / gist:1294725
Created October 18, 2011 06:06 — forked from claudiolassala/gist:1294722
HTTParty parser
class Foo
include HTTParty
parser Proc.new {|data| ...}
end
x = if y == 2 then 3 else 4
$ ->
$(document).on 'click', '.sf-close a', ->
$(this).parent().parent().hide()
@axsuul
axsuul / student.rb
Created January 25, 2012 19:31 — forked from anonymous/search function
syntax error
class Student < ActiveRecord::Base
def self.search(query)
find(:all, :conditions => ['student_name LIKE ?', "%#{query}%"]) || []
end
end
1: <ul>
2: <% Student.search("Jamie").each do |student| %>
3: <li><%= link_to Student.student_name,
4: :action => 'show', :id => Student.id %></li>
5: <td><%=h student.student_name %></td>
@axsuul
axsuul / gist:1754674
Created February 6, 2012 20:38 — forked from vpamulap/gist:1754562
This is the code used to replace a recipe on a page using ajax.
______________________________________________
Link to Action in View:
______________________________________________
<%= link_to image_tag("refreshIcon.png"), replace_meal_queue_recipe_path(meal_queue_recipe), method: :post, remote: true %>
______________________________________________
Controller:
______________________________________________
class MealQueueRecipesController < ApplicationController
# GET /meal_queue_recipes