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
# the current index action in SolutionsController (for comparison purposes) | |
# app/controllers/solutions_controller.rb | |
def index | |
@problem = Problem.find(params[:problem_id]) rescue (redirect_to "/" and return) | |
if !current_user_admin? && (@problem.nil? || [email protected]?(current_user)) | |
redirect_to @problem and return | |
end | |
@top_solutions = Solution.where(problem_id: @problem.id, user_id: { "$nin" => [current_user.id] }). | |
desc(:score).desc(:updated_at).page(params[:page] || 1) |
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
# | |
# Documenting io/nonblock and how the methods (nonblock?, nonblock=, nonblock{}) there behave | |
# | |
# server.rb | |
require 'socket' | |
TCPServer.open('localhost', 3030) do |server| | |
while client = server.accept |
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'active_support/all' | |
require 'digest/sha1' | |
def leftrotate(value, shift) | |
return ( ((value << shift) | (value >> (32 - shift))) & 0xffffffff) | |
end | |
# FIPS 180-2 -- relevant section #'s below |
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
What I'm trying to accomplish: | |
- Updating Bundler version from 1.0.22 to 1.3.0 so it's compatible with Rails 4, | |
and then updating to Rails 4.0.0.beta1 | |
Command I ran: | |
- gem update bundler (successfully installed bundler 1.3.0) | |
- bundle update rails (to 4.0.0.beta1 in gemfile) | |
What I expected to happen: | |
- For the rails gem to be updated |