...pattern below. The module pattern gives you basic class concepts like a constructor, private state, public methods. Since the module pattern only uses basic JavaScript, your code will run in...
...that we want to translate into Javascript using the module pattern. It's a simple class with one private function: # Ruby class Dog def initialize(name) @name = name
2.ordinalize # => "2nd" 1002.ordinalize # => "1002nd" 1003.ordinalize # => "1003rd" -11.ordinalize # => "-11th" -1001.ordinalize # => "-1001st...
Here is some JavaScript code that allows you to click the screen and get the clicked element's text contents (or value, in case of inputs). The approach is simple...
...element. When you click the overlay, we look up the element underneath it and show its text in a browser dialog. You can then copy it from there.
When CoffeeScript was added to Rails 3.1 they forgot one very important part, the ability to use it when responding...
...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'
...spinner', '~> 0.2.5' gem 'launchy', '~> 2.1.2' With these versions set, selenium-webdriver will be at version 2.35.1. This is because all later versions depend on rubyzip 1+. More info. After upgrading...
By default, Devise redirects to a sign-in form when accessing a route that requires authentication. If for some reason you do not want this, but use Basic Authentication (and...
...disable password reset. Note that forcing Basic Auth means there won't be a pretty sign-in form any more which would include a link for sign-up or password...
TL;DR Debugging problems with javascript errors in cucumber tests is sometimes easier in the browser. Run the test, stop at the problematic point (with Then pause from Spreewald...
...and open VNC for Firefox. Features: It does not freeze your server like when you're using a debugger. (Compared to the Then console step) It enables interacting with the...
...aws-credential-file ./aws-credential.txt The output should look something like this: arn:aws:iam::322191361670:server-certificate/www.example.com arn:aws:iam::322191361670:server-certificate/testCert Now you have to upload...
...and includes the server certificate Amazon Resource Name (ARN) and GUID: arn:aws:iam::322191361670:server-certificate/www.example.com-2011 ASCACexampleKEZUQ4K If you got the error message similar to A client error...
...class for the presenter instead of extending objects DCI-style. This allows them to add statically-defined callbacks and validations from ActiveModel with the syntax that we know and love...
...question: We should be clear about why a form model is a better place for screen-specific code than a plain old controller. Weren't controllers originally the place for...
...To reconfigure later, call s3cmd --configure. Once you're done setting up, s3cmd gives you shell-like commands like s3cmd ls or s3cmd del somefile.png. Here is a full list...
s3cmd accesslog s3://BUCKET Sign arbitrary string using the secret key s3cmd sign STRING-TO-SIGN Sign an S3 URL to provide limited public access with expiry
Let's say you have two screens: Show a given project Show a report for all projects Ideally you want both screens to be handled by different controllers like this...
...action ProjectsController#report. But these are all unsatisfying. What you can do is wrap the sub-resource in a collection block like you would do with custom collection actions:
Using CSS sprites for background images is a technique for optimizing page load time by combining smaller images into a larger image sprite. There are ongoing arguments on how useful...
...this still is, as modern browsers become more comfortable to load images in parallel. However, many major websites still use them, for example amazon, facebook, or twitter.
We often use VCR to stub external APIs. Unfortunately VCR can have problems matching requests to recorded cassettes, and these issues are often hard to debug. VCR's error messages...
...any way it will assume an error, because it can not know how the system it mocks would answer a request it has not yet recorded. Some signs an error...
...signal("mouse::enter", function(c) local focused = client.focus if focused and focused.class == c.class and focused.instance == "sun-awt-X11-XDialogPeer" and c.instance == "sun-awt-X11-XFramePeer" then return end if awful.layout.get...
...change that one). Known issues This will not affect "find anything" as IntelliJ uses a sun-awt-X11-XFramePeer for it. There are no properties which allow distinguishing the "find...
...truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. This will cause horrible, data-destroying bugs...
...this reason you should probably not use GROUP_CONCAT ever. At least you must set the value of group_concat_max_len to an insanely high value on every database...
gem install ruby-debug (Ruby 1.8) or gem install debugger (Ruby 1.9) Start your server with script/server --debugger Set a breakpoint by invoking debugger anywhere in your code...
...path that crosses the breakpoint Once you reach the breakpoint, the page loading will seem to "hang". Switch to the shell you started the server with. That shell will be...
If you need to capture signatures on an IPad or similar device, you can use Thomas J Bradley's excellent Signature Pad plugin for jQuery. To implement, just follow the...
...steps on the Github page. The form If you have a model Signature with name: string, signature: text, you can use it with regular rails form like this:
...CSS but it does not fit fancy requirements. Here is a hack for the special case where you want to truncate one of two strings in one line that can...
...both vary in length, while fully keeping one of them. See this example screenshot where we never want to show an ellipsis for the distance: You can try pretty hard...
...have a useful blank? method. It returns true for nil but also for empty strings or empty arrays. There is also a universal method present? which returns true for all...
...may also use up.util.isBlank(). By default, this function returns true for: undefined null Empty strings Empty arrays A plain object without own enumerable properties All other arguments return false.
Microsoft Exchange service administrators can enable Exchange Web Services (EWS) which is a rather accessible XML API for interacting with Exchange. This allows you to read and send e-mails...
...meeting attendees, track responses, manage to-do tasks, check user availability and all other sorts of things that are usually only accessible from Outlook. You can implement an EWS by...
Sometimes, you may want to open up a second database connection, to a read slave or another database. When doing that, you must make sure you don't overwrite an...
...will actually cause all kinds of trouble: def with_other_database ActiveRecord::Base.establish_connection(slave_settings) yield ensure ActiveRecord::Base.establish_connection(master_settings) end Putting aside that you are setting...
Sometimes you need to monitor a connection from your machine to a specific, single host or network in order to identify which network hop between your machine and the target...
...causes trouble. You can use the following shell script to easily achieve this kind of monitoring. If the target host is unable to respond to the specified number of ICMP...
...did not happen yet you should use cap deploy:migrations. The problem Let's say that you have something like that in your config/deploy.rb to create a database dump every...
...called for cap deploy:migrations. The same applies to other things that are hooked similarly, like an after 'deploy', 'craken:install'. How to avoid it When looking at the default...
Geordi uses parallel_tests if available for running the test suite. To debug an application it is very unhandy to have multiple processes as your terminal I/O will not work...
...as expected once a breakpoint is hit. Even parallel_tests support an option to enable a single process run, it is not possible to pass this option through geordi. But...