Skip to content

Instantly share code, notes, and snippets.

View Mayurifag's full-sized avatar
🗨️
I may be slow to respond.

Mayurifag

🗨️
I may be slow to respond.
View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@pahanix
pahanix / gist:885671
Created March 24, 2011 19:22
Clear your logs in development automatically when they are too large.
# config/initializers/clear_logs.rb
# This snippet simply clears your logs when they are too large.
# Large logs mean looooong search in TextMate. You know it :)
# Every time you run rails server or rails console it checks log sizes
# and clears the logs for you if necessary.
if Rails.env.development?
MAX_LOG_SIZE = 2.megabytes
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@samnang
samnang / 1_decorator.rb
Created September 15, 2013 03:21
Decorator vs Form Object vs Service Object?
class FacebookCommentNotifer
def initialize(comment)
@comment = comment
end
def save
@comment.save && post_to_wall
end
private
@subelsky
subelsky / aliases.sh
Created October 17, 2013 14:05
Useful aliases for Ruby and Rails development and git maintenance
alias a='ack'
alias a?='alias | grep -i'
alias adx='rake db:drop && rake db:create && heroku pg:transfer --from black --to postgres://postgres@localhost/staq_development --confirm staqweb --app staqweb && rails r "User.all.each { |u| u.update_attribute(:password,%q(password)) }" && rake db:test:prepare'
alias b='bundle'
alias bb='bundle install --binstubs=.bundle/bin --path=.bundle/gems && bundle package --all && reload ; sd'
alias bc='bin/console'
alias be='bundle exec'
alias bea='bundle exec annotate'
alias bu='bundle update'
alias bus='bundle update staq_extraction'
@yannvery
yannvery / 0_Paginate_without_reload_all_page_with_kaminari.md
Last active November 3, 2022 11:11
How to paginate on an ajax way ( with jquery and kaminari )

Paginate with Kaminari without reload all data

Use :remote => true option on link_to and paginate Region index page

@germanny
germanny / _instructions.md
Last active May 24, 2024 17:44 — forked from jimmynotjim/_instructions.md
Instructions for setting up OSX

Setup OSX with a Clean Install

About once a year, my machine gets pretty sluggish and it's time to start fresh. Here's the process I use to update it with everything I need.

TODO: Add info about dotfiles set up and zsh (possible settings file?)

  • Save all dotfiles to a repo for easy transfer
  • Back up all photos, music, apps, iTunes library, keychains, etc.
@lfender6445
lfender6445 / gist:9919357
Last active July 3, 2024 20:50
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@brianburridge
brianburridge / gist:8d2755a73dd5b4f0332b
Created December 10, 2014 19:47
Export local db to JSON
namespace :json do
desc "Export all data to JSON files"
task :export => :environment do
Rails.application.eager_load!
ActiveRecord::Base.descendants.each do |model|
file = File.open(File.join(Rails.root, "db", "export", "#{model.table_name}.json"), 'w')
file.write model.all.to_json
file.close
end