This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I got an opportunity to learn Jquery in my last project, The user interface quite resembles with the Facebook. | |
I have to impelement Facebook like autosuggest with tagging support, There are number of Jquery plugins available which does this, | |
i found most of them incomplete or not to easy to modify | |
I choose http://code.drewwilson.com/entry/autosuggest-jquery-plugin, because of beautifully written ruby and easy customizable. | |
The full description of this plugin can read at above addr. | |
However understanding some of the options is little confusing like 'format list' callback | |
In this post you will see how to use this callback with server side rails ruby working out of the box :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#SCRIPT TO CREATE CLASSES AND METHODS DYNAMICALLLY ON THE BASIS OF CSV FILE | |
def check_usage | |
unless ARGV.length ==1 | |
puts "Usage: You must input some file in csv format." | |
exit | |
end | |
end | |
#--------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of how you can to use Capybara with plain Rails' integration tests and FactoryGirl (or plain MyModel.create…) | |
require 'test_helper' | |
require 'capybara' | |
require 'capybara/dsl' | |
require 'database_cleaner' | |
Capybara.app = Pardy::Application | |
Capybara.default_driver = :rack_test | |
DatabaseCleaner.strategy = :truncation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'save_me' | |
class User | |
include SaveMe | |
attr_writer :first_name, :last_name, :age, :about | |
validates_presence_of :last_name, :first_name | |
# validates_length_of :last_name, :minimum => 1, :maximum => 7, :if => :me | |
# validates_uniqueness_of :first_name, :if => Proc.new { |user| user } | |
# validates_format_of :first_name,:with => (/thid/), :if => Proc.new { |user| user } | |
# validates_length_of :first_name, :if => Proc.new { |user| user } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module OmniAuth | |
module Strategies | |
# tell OmniAuth to load our strategy | |
autoload :Pixelation, 'lib/pixelation_authorization' | |
end | |
end | |
Rails.application.config.middleware.use OmniAuth::Builder do | |
provider :twitter, "app_name", "secret" | |
provider :facebook, "app_name", "secret", :scope => '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DS_Store | |
*.log | |
Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Article | |
attr_reader :filename | |
def initialize(filename) | |
@filename = filename | |
end | |
def <=> other | |
self.filename <=> other.filename | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#gem install 'ruby-breakpoint' | |
require 'rubygems' | |
require 'breakpoint' | |
class Person | |
def initialize(name, age) | |
@name, @age = name, age | |
breakpoint("Person#initialize") | |
end | |
attr_reader :age |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mysql2' | |
client = Mysql::Client.new(:host => "localhost", :username => "root") | |
# Fetch running threads | |
processes = client.query("SHOW FULL PROCESSLIST") | |
processes.each do |process| | |
# Kill thread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul class="social-links"> | |
<li class="facebook"><%= link_to "Like us on Facebook", facebook_path %></li> | |
<li class="twitter"><%= link_to "Follow us on Twitter", twitter_path %></li> | |
</ul> |
OlderNewer