There are several gems that make it easy to read and process xlsx files. Parsing the entire file at once however is error-prone since each cell is transformed to...

...formatted but empty cells. As of today, I found two promising alternatives that provide a stream-based access to spradsheet rows: Roo supports multiple spreadsheet types like ODS or CSV...

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:

...code from your repository. In order to do so, Capistrano connects to your repository server from the application server you're deploying to with SSH. For this connection you can...

...use two SSH keys: the user's ~/.ssh/id_rsa [default] the very same key you used for connecting to the application server - forwarded automatically to the git repository.

makandra dev

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...

class Foo def bar(argument) 'Hello' + argument end end module FooExtensions def bar super(' in my') + ' World' end end class Foo prepend FooExtensions # the only change to above: prepend...

makandra Curriculum

...offers an 8 month paid trainee program 🇩🇪 for junior developers that are looking to start a professional career in web development. This curriculum contains goals, resources and code exercises for...

...When an exercise asks you to do multiple versions, these should be reviewable as separate commits or branches. After the review with mentor you can keep the best version and...

...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...

...as expected with your Unpoly app. This is because your app only has a single page load when the user begins her session. After that only fragments are updated and...

...up.compiler('[track-for-analytics]', function($element) { var url = $element.attr('track-for-analytics') || location.pathname; ga('set', 'page', url); ga('send', 'pageview'); }); Finally look for containers that represent trackable content, and give...

...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...

makandra dev

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...

...call model.save! after recreating versions. uploader.recreate_versions! does not update the model with the stored filename...

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...

github.com

...an attacker might be able to use this to inject javascript code into the source code of your page. The linked github page is a collection of common markdown XSS...

...which is handy for writing tests. Producing arbitrary links: [Basic](javascript:alert('Basic')) [Local Storage](javascript:alert(JSON.stringify(localStorage))) [CaseInsensitive](JaVaScRiPt:alert('CaseInsensitive')) [URL](javascript://www.google.com%0Aalert('URL'))

...are close to given coordinates you can use the Graticule gem. Graticule Graticule offers several methods to compute the distance between two geo-dated objects but fetching records from the...

...radius of a location is a bit trickier: def close_destinations(latitude, longitude) distance_sql = Graticule::Distance::Spherical.to_sql(:latitude => latitude, :longitude => longitude, :units => :kilometers) Destination.all(:conditions => [ "#{distance_sql...

When you click a link or a press a button on a Selenium-controlled browser, the call will return control to your test before the next page is loaded. This...

...can lead to concurrency issues when a Cucumber step involves a Selenium action and a Ruby call which both change the same resources. Take the following step which signs in...

ariejan.net

...you create columns in a migration. Its meaning depends on the column type, and sometimes the supplied value. The documentation states that :limit sets the column length to the number...

...of characters for string and text columns, and to the number of bytes for binary and integer columns. Using it This is nice since you may want a bigint column...

require 'logger' log = Logger.new('log/mylog.log') log.info 'Some information' log.debug 'Debugging hints' log.error StandardError.new('Something went wrong') Logger does a number of things well: Message type (info / debug / error...

Log entries are timestamped Writing log output is synchronized between threads Logged errors are printed with full backtraces If you don't like the output format, you can...