When you want to do a
git diff but do not care about the full diff and just want to know which files changed, use the
$ git diff --name-only app/controllers/sessions_controller.rb app/models/user.rb features/sign_in.feature
To include some brief information about changed lines, use the
$ git diff --stat app/controllers/sessions_controller.rb | 8 +- app/models/user.rb | 30 ++++ features/sign_in.feature | 136 +++++++++++++++++
When you download or upgrade RVM it has a hardcoded notion which patch level it considers to be "1.9.3".
This can give you errors like
"ruby-1.9.3-p392 is not installed" even if you have another Ruby 1.9.3 that will do.
The solution is to define an alias:
rvm alias create 1.9.3 ruby-1.9.3-p385
Another solution is to use rvm with the fuzzy flag, as stated by mpapis.
rvm use --fuzzy .
This will make rvm more intelligent in the Ruby selection. To always do fuzz…
tl;dr: Ruby's Bundler environment is passed on to system calls, which may not be what you may want as it changes gem and binary lookup. For a bundler-free environment, use
Bundler.with_clean_env. Do this whenever you want to execute shell commands inside other bundles.
Consider this setup:
my_project/Gemfile # says: gem 'rails', '~> 3.0.0' my_project/foo/Gemfile # says: gem 'rails', '~> 3.2.0'
And, just to confirm this, these are the installed Rails versions for each of the bundles:
This only works when you actually have a session ID (not the case for Rails' CookieStore, for example):
request.session_options[:id] # => "142b17ab075e71f2a2e2543c6ae34b94"
Note that it's a bad idea to expose your session ID, so be careful what you use this for.
Note: This technique is confusing and slows down your test suite.
Copy the attached code to
features/support. This gets you a new Cucumber tag
@no_parallel which ensures that the tagged scenario does not run in parallel with other scenarios that are tagged with
@no_parallel. Other scenarios not tagged will
@no_parallel can still run in parallel with the tagged test. Please read the previous sentence again.
This can help when multiple test processes that access a single resource that is hard to shar…
Depending on where you live, different rules are used to determine the number of the week and a weekday. You have no chance whatsoever to get this right globally unless you make it your life's purpose. However, when you work for clients from Europe or the US, there are two dominantish standards you should know about. Each of these has subtle differences.
This is stupid. Fix it like this:
When using the json gem, you might run into this error when using
>> json = 'foo'.to_json >> JSON.parse(json) JSON::ParserError: 757: unexpected token at '"foo"' from /.../gems/json-1.7.7/lib/json/common.rb:155:in `parse' from /.../gems/json-1.7.7/lib/json/common.rb:155:in `parse' from (irb):1
The error above happens because the JSON you supplied is invalid.
to_json does work correctly, the result itself is not JSON that can be parsed back, as that s…
In specs, the session never persists but is always a new object for each request. Data put into the session in a previous request is lost. Here is how to circumvent that.
You are making
ActionController::TestRequests in your specs, and their
#initialize method does this:
self.session = TestSession.new
This means that each time you say something like "
get :index", the session in your controller will just be a new one, and you won't see …
Say you want to allow users to emphasize some string, but the whole markdown thing would be far too much. The helper method below does a basic replacement of
**some text** with
<%=md @question.title %>.
def custom_markdown(prose) markdown = String.new.html_safe markdown << prose.to_str # make sure the prose gets escaped, even if it is an html_safe string markdown.gsub(/(\*\*)(.*?)(\*\*)/, '<strong>\2</strong>').html_safe end alias_method :md, :custom_markdown
Create a directory
Initialise git repository
cd ~/.aws && git init
Create a git branch with a name you want (e.g.
development for the aws development account credentials).
Add AWS credential file
Also add your EC2 cert and private key file.
You can add other AWS account depending files like
Create symlinks for some config files like
ln -s ~/.aws/.aws_credentials ~/.aws_cred...
We ran into trouble when adding additional compute units to our railscomplete Hosting environment lately.
VM-instances on the new compute units where booting and requesting private IP addresses via DHCP correctly (
DHCPDiscover), but after the answer of the dnsmasq dhcp server (
DHCPOffer) we did not see any further traffic on the host machine. FYI: The instance should request the IP via
DHCPRequest which in turn should be acknowledged by a
We assumed this DHCP UDP traffic did not…
Awesome battle report from Pinterest trying to scale their setup using different approaches.
When you push something to the limit all technologies fail in their own special way. This lead them to evaluate tool choices with a preference for tools that are: mature; really good and simple; well known and liked; well supported; consistently good performers; failure free as possible; free. Using these criteria they selected: MySQL, Solr, Memcache, and Redis. Cassandra and Mongo were dropped.
jQuery plugin to fire events when user's cursor aims at particular dropdown menu items. For making responsive mega dropdowns like Amazon's.
Non-SSL contents on SSL pages are blocked by default
Bug 834836 – Turn on pref to block mixed active content
Firefox 18 introduced preferences to block loading contents from non-SSL (http) sites on SSL (https) pages. One of those preferences, security.mixed_content.block_active_content is now enabled by default in order to enhance user security. That means insecure scripts, stylesheets, plug-in contents, inline frames, Web fonts and WebSockets are blocked on secure pages, and a notification is displayed instead. It will not block…