This file contains hidden or 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 'spec-helper' | |
describe UserController do | |
describe "Search user with name" do | |
it "should respond to search user route" | |
it "should call User model method to search user with same name" | |
it "should show view with the list of matching users" do | |
response.should render_template("matching_users") | |
it "should redirect to index page if not found" do | |
response.should redirect_to(:action => ) |
This file contains hidden or 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
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin` | |
# Be sure to have rails and thin installed. | |
require "rubygems" | |
# We are not loading Active Record, nor the Assets Pipeline, etc. | |
# This could also be in your Gemfile. | |
gem "actionpack", "~> 3.2" | |
gem "railties", "~> 3.2" | |
# The following lines should come as no surprise. Except by |
This file contains hidden or 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
a = "12345" | |
# a[i:j:k] from i to j in steps k | |
s = a[::-1] | |
print s | |
# '54321' |
This file contains hidden or 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
k = 1 | |
r = 3 | |
c = 5 | |
# Correct way | |
A = [[ k ] * c for i in range(r)] | |
A[0][3] = 0 | |
#>>> A | |
#[[1, 1, 1, 0, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]] |
This file contains hidden or 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
public class ShutdownListener implements ServletContextListener { | |
@Override | |
public void contextDestroyed(ServletContextEvent sce) { | |
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext()); | |
P p = (P) ctx.getBean("proc"); | |
p.shutdown(); | |
} | |
} |
NewerOlder