...a TimeWithZone). You need to use Time.current, Date.current, DateTime.current, Time.zone.parse, etc. everywhere. You should read this guide for a pretty exhaustive list of all the things you need to pay...

...Rails 3, open config/environment.rb and define your time zone: config.time_zone = 'Berlin' Again, please read the working with time zones in Ruby on Rails from Elabs before you do anything...

...place where the application usually gets its keys from. The keytool is able to read certificate files but does not understand private key files which you need to use your...

...application created by AgentBob and also attached to this note. You do want to read through such code first and not mindlessly use it on your private keys.

...using this regularly, as it has high potential to make your tests hard to read and understand. You're often better of by using factories, generally different implementation patterns, or...

miekd.com

...the article using a different formatting style so that it jumps out at the reader. Blatantly copying the excerpt of the pull quote into it’s own element is not...

...a structural representation of the excerpt would be seen twice by people using feed readers or services like Instapaper, as well as be re-read for people who use screen...

To read the Rails session from a Rack middleware, use env['rack.session']. It's an ActionDispatch::Request::Session object. class MyMiddlware def initialize(app) @app = app end def call(env...

If you need to capture signatures on an IPad or similar device, you can use Thomas J Bradley's excellent...

...seems not as obvious as if you are using JSON. To safely write and read YAML files you should use Psych#dump (String#to_yaml) and Psych.safe_load (YAML.safe_load...

You can use heredoc to avoid endlessly long lines of code that nobody can read. Heredoc strings preserve linebreaks and can be used like this: def long_message

...cap production app:logs 00:00 app:logs 01 tail -n0 -F /var/www/your-application/shared/log/production.log | while read line; do echo "$(hostname): $line"; done 01 app01-prod: Started GET "/sign_in" for 1.2.3.4 at...

...LOG'] || fetch(:rails_env) execute %(tail -n0 -F #{shared_path}/log/#{logfile}.log | while read line; do echo "$(hostname): $line"; done) end end end If you have some other log...

paweldabrowski.com

...use a form object here" You can learn about new code patterns You should read the sections "Advantages of using design patterns" and "Disadvantages of using design patterns in a...

makandra dev
mupdf.com

MuPDF is a PDF reader that renders very quickly, yet still correctly. It supports PDF 1.7 and all the fancy shenanigans that evince (Ubuntu's default PDF reader) fails to...

...your latest-version PDF documents properly, you probably still have to resort to Adobe Reader or the lp command...

makandra dev
alan.norbauer.com

Call and Debug a Function Pause Execution on URL Change Debugging Property Reads Use copy() Debugging HTML/CSS

makandra dev
github.com

"rock it Español style".to_url => "rock-it-espanol-style" "tell your readers 你好".to_url => "tell-your-readers-ni-hao" The above conversions of special chars, like...

...conditions => ['state = ?', 'draft']) or a hash (:conditions => { 'state' => 'draft' }). The later is nicer to read, but has horrible security implications in some versions of Ruby on Rails. Affected versions

...Encoding.default_external, notably the string inside a StringIO.new some strings created via CSV files read from disk strings read from an IRB Encoding.default_external defaults to whatever locale charmap says...

makandra dev
tldp.org

...Applied to files > creates or overwrites a file >> creates or appends to a file < reads from a file, where < is taken as 0< Note: You should be pretty sure of...

...grep da * 1>&2 everything: do_stuff &> /dev/null combined: command < input-file > output-file, reads from input-file and writes stdout to output-file

...it with two niceties: support for passing a block (which could e.g. render a "read on" link), and html_safe knowledge. Prefer the truncate() helper Warning: truncate() calls html_safe...

The code below shows a method #validate which uses Nokogiri to validate an XML document against an XSD schema. It...

file.write open('http://example.com/your.file', :http_basic_authentication => [your_username, your_password]).read

...line tool and client for uploading, retrieving and managing data in Amazon S3. S3cmd reads its configuration by default from ~/.s3cfg, which is created once you run s3cmd --configure.

...htpasswd -v htpass_test firstname.lastname You probably should not use the -b switch to read the password from the command line as the password will then be visible in your...

...values for the current scope, similar to # ActiveRecord's `ids` method. For performance, we read id and type # directly from the database and create GIDs from them. # Note that we...

When you need the DOM node of a tag (e.g. to read extra attributes, or to modify the DOM near it), you can usually reference it via document.currentScript. However, document.currentScript is unsupported in ancient browsers, like Internet Explorer 11 or wkhtmltopdf's Webkit engine. If you are not running async scripts, you can easily polyfill it: document.scripts[document.scripts.length - 1] It works because document.scripts grows with each tag that was evaluated. That is also the reason why this solution will not work reliably for async code. Demo: https://codepen.io/foobear/pen/poRLxQm

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

...Creek since a badly formatted 12MB Sheet broke the 500MB Staging Memory limit when reading it as a whole. The implementation follows the Creek's documentation: document = Creek::Book.new('/path/to/file.xlsx...