We usually generate our commit messages from Pivotal Tracker IDs and titles, like
[#15775609] Index view for conflicts
The geordi command commit
automates this. (See: Pretty Commit messages via geordi).
Just run geordi commit
and it will connect to PT and let you select from a list of all started and finishes stories. Then it runs git commit
with the generated message (i.e. all staged changes will be commited).
When running for the first time, Geordi will request your PT...
When you generate a URL in a mailer view, ActionMailer
will raise an error unless you previously configured it which hostname to use.
There are two options to set the default_url_options
of ActionMailer:
When you are sending mails from outside the request cycle, e.g. ActiveJob/Sidekiq or Cronjobs, y...
Thunderbird 5 brings a custom chrome on Windows Vista/7 that uses translucent Aero decorations on toolbars and menubars. Here is how to restore solid backgrounds if you don't like it.
Put the following into chrome\userChrome.css
in your Thunderbird profile directory:
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
window {
background-color: -moz-dialog !important;
}
(Re-)start Thunderbird afterwards.
If you need more info on where the userChrome.css
is suppose...
Here is how to switch your Selenium to Chrome:
$PATH
See also geordi chromedriver_update which is automatically executed before every usage of geordi cucumber
.
Create a file features/support/capybara.rb
with the following content for recent version of Capybara:
Capybara.register_driver :selenium do |app|
Capyb...
Sometimes, when running a rake task, RubyGems 1.8.5 raises an error:
rake aborted!
undefined method `specifications' for "/usr/lib/ruby/gems/1.8":String
This has been fixed since May 31 but is still not available as a new RubyGems version.
Either wait for a new version to eventually come out, downgrade to some really old version (1.6.2 works for some) or apply the fix manually:
When CoffeeScript was added to Rails 3.1 they forgot one very important part, the ability to use it when responding to JavaScript (JS) requests!
In Rails 3.1 it’s incredibly easy to build your application’s JavaScript using CoffeeScript, however if you fire off an AJAX request to your application you can only write your response using regular JavaScript and not CoffeeScript, at least until CoffeeBeans came along.
Get "PuTTY Link" and "Pageant" (an SSH key agent) from the PuTTY download page.
Run pageant.exe
, find its icon inside your system tray and add your SSH key.
Open up a cmd
and put the full path to PuTTY's plink.exe
into the GIT_SSH
environment variable, e.g.:
set GIT_SSH=D:\PuTTY\plink.exe
You can then use Git like you would on any sane operating system. Just go ahead and git clone
, git pull
, etc.
Also, you may want to add the environment vari...
Because your examples should not change global state, you should not need to care about the order in which RSpec processes your .rb
files. However, in some cases you might want to know.
.rb
files in alphabetical order of their file paths by default (or when you specify --order defined
).In order to request a SSL certificate from any dealer, you usually need a CSR certificate. As both the CSR as well as key are created in this step, make sure you save this certificate on a trusted, secure machine only. Usually this is your production environment.
Run this on the server (not on your machine) as root.\
Replace your-domain.tld with the domain you request the certificate for and YYYY with the current year so you will not have any conflicts when requesting a certificate next year.
openssl req -new -sha256 -out www.your-dom...
This snippet makes links that refer to an anchor (like "<a href="#something">...</a>
") scroll softly to it.\
In this example we only do it for links that also own a data-animate
attribute.
$('a[href^="#"][data-animate]').live('click', function() {
var hash = $(this).attr('href');
var offset = $(hash).offset();
if (offset) {
$('html, body').animate({ scrollTop: offset.top }, 'slow');
location.hash = hash;
return false;
}
});
Note that this could basically work for any element whos...
This is just a reference for legacy code. For new code, always use capture3
.
Returns the standard output of running the given command in a subshell. This is an alias for `...`, and you can use string interpolation.
Example:
name = 'ls'
result = `which #{name}`
It does not escape anything you inject in the string, so be aware of possible security vulnerabilities...
Today I needed to execute a ruby gem executable with sudo
. But, surprisingly, bash would tell me command not found
for the gem that ran lovely without sudo
.
Gem bin
s are installed to /var/lib/gems/1.8/bin
, which is not in sudo’s PATH
. Unfortunately, you can’t change the path, since sudo
for Ubuntu is compiled with the --with-secure-path
option.
#Solution A: symlink the gems (if you need only some few gems)
sudo
, run `ln -s /var/lib/gems/1.8/bin/gem_for_sudo /usr/local/bin/gem_for_sudo#Soluti...
We use the lambda-technique to DRY up our Rails routes machinist blueprints, and, of course, RSpec examples.
We recently decided to put static content for HouseTrip.com to Amazon Cloudfront for a faster user experience. This happens fully automatically on deploy and is transparent in development. Together with a heavy use of sprites this sped up page load time quite nicely.
These are a couple of the problems you need to solve in order to do this:
When deploying an application with "cap deploy
" by default [1] you only deploy your code but do not run migrations. To avoid an application to be running with code which requires database changes that did not happen yet you should use cap deploy:migrations
.
Let's say that you have something like that in your config/deploy.rb
to create a database dump every time you deploy:
before 'deploy', 'db:dump'
This will not be called for cap deploy:migrations
. The same applies to other things that are hooked s...
You set a flash message and it shows up as it should. However, it is displayed again the next time you follow a link. Here is why:
You have to differentiate between a render
and a redirect_to
because a flash message is only deleted after a redirect. If you want a message to be seen in the next request after a redirect, use flash[]
. If you want a message to be seen in the current request, use flash.now[]
.
If you cannot be bothered to decide which flash hash to use, or if the fl...
Reading a URL via GET:
curl http://example.com/
Defining any HTTP method (like POST or PUT):
curl http://example.com/users/1 -XPUT
Sending data with a request:
curl http://example.com/users -d"first_name=Bruce&last_name=Wayne"
If you use -d
and do not set an HTTP request method it automatically defaults to POST.
Performing basic authentication:
curl http://user:password@example.com/users/1
All together now:
curl http://user:password@example.com/users/1 -XPUT -d"screen_name=batman"
...
The Basic Authentication header encodes username and password. Effectively, it's just Base64 plus a "Basic
" prefix.
You can use ActionController::HttpAuthentication::Basic.encode_credentials
for that, and put its result into the Authorization
request header.
For request specs, use the :header
option.
it 'requires authentication' do
get '/'
expect(response.status).to eq(401)
end
it 'accepts valid credentials' do
encoded_credentials = ActionController::HttpAuthentication::Basic.encode_credentials(use...
When installing RMagick you may get an error messages like this:
Version 2.13.1:
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.1. Can't find Magick-config in /home/arne/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/var/lib/gems/1.8/bin
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
d...
By default, Opera 11 hides any passed params and the URL's protocol until you focus the address bar.
To disable hiding URL parameters, open up Tools → Preferences (Ctrl+F12) → Advanced → Browsing and check "Show full web address in address field". No need to touch opera:config.
The badge that displays the page's "zone" (Web, Secure, Opera, ...) will be shrinked so you can still see a yellow lock for proper SSL connections, etc.
Artifice allows you to replace the Net::HTTP subsystem of Ruby with an equivalent that routes all requests to a Rack application.
You can use Sinatra, raw Rack, or even Rails as your application, allowing you to build up an equivalent to the remote service you are mocking out using familiar and convenient tools to route requests and build up responses.
Within an event handler, there are multiple methods to cancel event propagation, each with different semantics.
event.preventDefault()
Only prevents the default browser behavior for the click, i.e. going to a different url or submitting a form.
When invoked on a touchstart
event, this also prevents mouse events like click
to be triggered.
event.stopPropagation()
Prevents the event from bubbling up the DOM.
`event.st...
The information in this card is only relevant for Rails 2.3-era apps.
This note gives a quick introduction into caching methods (page caching, action caching and fragment caching) in rails and describes some specific problems and solutions.
The descriptions below are valid for Rails 2 and 3. Recently, caching with timestamp- or content-based keys has become more popular which saves you the pain of invalidating stale caches.
To enable or disable caching in rails you ca...
Specify these gem versions in your Gemfile:
gem 'cucumber', '~> 1.3.0'
gem 'cucumber-rails', '= 0.3.2' # max version for Rails 2
gem 'capybara', '< 2' # capybara 2+ requires Rails 3
gem 'mime-types', '< 2' # dependeny of capybara
gem 'nokogiri', '< 1.6' # dependency of capybara
gem 'rubyzip', '< 1' # dependency of selenium-webdriver, rubyzip 1+ requires Ruby 1.9
gem 'cucumber_factory'
gem 'database_cleaner', '< 1'
gem 'cucumber_spinner', '~> 0.2.5'
gem 'launchy', '~> 2.1.2'
With these versions set, `...