stackoverflow.com

...that whenever you are using those values for database interaction, you'll end up scoping on the wrong records since the database representation of these dates is not converted to...

Use form models to handle this problem Or soften the validation to validates_presence_of :parent Usually you would validate presence of parent object id, like in this...

validates_presence_of :parent_id # <- end With the parent already persisted creating nesteds still works fine. But one will encounter a 'parent id missing' error on creating a parent...

...You can add other AWS account depending files like .fog or .guignol.yml too. Create symlinks for some config files like .aws_credentials and .fog: ln -s ~/.aws/.aws_credentials ~/.aws_credentials

...export EC2_CERT=~/.aws/cert-ec2.pem export AWS_CREDENTIAL_FILE=~/.aws/aws-credentials Perhaps you also want to set a default region and the JAVA_HOME: export EC2_REGION=eu-west-1

Say you have an RGBA color that you need as a non-transparent color because of reasons. Basically, this is possible. Just understand that you will convert your RGBA color...

...your background is white, so you'll use #fff as that for examples below. Simple approach When your know the RGBA color's base RGB color (e.g. your brand color...

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. What's going on? 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...

github.com

Barby is a great Ruby gem to generate barcodes of all different sorts. It includes support for QR codes via rQRCode; if you need to render only QR codes, you...

>> Barby::Code128.new('Hello Universe').to_image.to_data_url => "data:image/png;base64,iVBORw0KGgoAA..." For super-crisp barcodes, render them as SVG. Printing images usually causes some level of blur...

...should), the host's IP address is: 10.0.2.2 You'll need it to access shared folders or your host's web server when testing pages in IE.

When you need to check a value for presence, don't rely on JavaScript since it considers 0 or "0" false. Also don't rely on LoDash's _.isEmpty:

While the name implies that it's meant only for collections, you probably still want something like isBlank or isPresent that return true/false for objects humans would normally consider...

amundsen.com

...but REST itself - in a nutshell. so here's a new angle i've started playing with: "REST Upside Down...

Accessing pseudo elements via JavaScript or jQuery is often painful/impossible. However, accessing their styles is fairly simple. Using getComputedStyle First, find the element in question. let element = document.querySelector('.my-element...

...s getComputedStyle. It takes an optional 2nd argument to filter for pseudo elements. let style = window.getComputedStyle(element, '::before') let color = style.getPropertyValue('background-color') The returned color will be a string...

linuxsa.org.au

...up little more than one extra line in the output of ps. On a server I want to get informed if there are zombie processes and track them with a...

...two choices, fix it or kill it. In this case it's no critical service and I can just restart it...

When using Savon to connect a SOAP API, you may want to use Savon::SpecHelper to mock requests in your tests as described in their documentation. When sending a message...

...body, the savon mock object requires a message to be set, like this: savon.expects(:action_name).with(message: { user_id: 123 }).returns(' ') If you want to stub only the returned...

If your Webpack build is slow, you can use the Speed Measure Plugin for Webpack to figure out where time is being spent. Note that at time of writing, Webpack...

...now have an idea where optimization might be feasible. Look around for suggestions, e.g. the sass-loader readme when you want to optimize Sass build time...

...on an old version of ImageMagick that you can no longer install in your system, you can choose the run an old ImageMagick in a Docker container. Dockerized ImageMagick commands...

...path arguments. You need to boot a corresponding docker container once before using it. Setting up Docker If you haven't installed Docker yet, use our guide or the official...

Find conditions for scopes can be given either as an array (:conditions => ['state = ?', 'draft']) or a hash (:conditions => { 'state' => 'draft' }). The later is nicer to read, but has horrible security...

...versions of Ruby on Rails. Affected versions Version Affected? Remedy 2.3.18 yes Use chain_safely workaround 3.0.20 no 3.1.x ??? 3.2.22 yes Use Rails LTS 3.2 with hardened configuration...

...require 'mathn' 2 / 3 => Rational(2,3) 2 / 3 * 3 => 2 While this might sometimes be quite neat, it's a nightmare if this gets required by some gem that...

...suddenly redefines integer division across your whole project. Known culprits are the otherwise excellent distribution and GetText gems (the later only when working with mo-files). To fix this, you...

patrickmarabeas.github.io

Webfonts are not always available when your JavaScript runs on first page load. Since fonts may affect element sizes, you may want to know when fonts have been loaded to...

...Promise that will be resolved once the font is available. Example: document.fonts.load('1rem "Open Sans"').then(() => {...

jQuery / fontSpy If your project uses jQuery, you could also use jQuery-FontSpy which...

makandra dev
github.com

The debugger gem does not seem to be properly working on Ruby 2. Use byebug instead! Byebug is a simple to use, feature rich debugger for Ruby 2. It uses...

...new TracePoint API for execution control and the new Debug Inspector API for call stack navigation, so it doesn't depend on internal core sources. It's developed as a...

When you create a temporary file (e.g. to store a generated Excel sheet) and try to send it to the browser from a controller, it won't work by default...

...this controller action: class FoosController < ApplicationController def download file = Tempfile.new('foo') file.puts 'foo' file.close send_file file.path end end Accessing this controller action will usually raise a 404 not found...

When using jQueryUI's Sortable plugin (either directly or via Angular's ui.sortable), you might struggle testing your nice drag&drop GUI since Selenium webdriver does not support native dragging...

But jQueryUI uses jquery.simulate for their testing, so why shouldn't you? There is even an extension to it that makes testing drag & drop quite easy.

It's generally not trivial to change a datetime's seconds, minutes, etc in SQL. Here is how it works when speaking PostgreSQL. Consider you have a timestamp column whose...

...seconds you want to zero: SELECT born_at FROM users; born_at --------------------- 2015-05-01 13:37:42 You can the TO_CHAR function to convert date or time values...

makandra dev

...an npm package. Naming convention for pre-release versions An npm package must use Semantic Versioning's naming convention for its version. In Semantic Versioning, the version number and pre...

...release identifier (like rc1) must be separated by a dash, like this: 1.0.0-rc1 2.3.0-alpha2 3.0.0-beta3 Publishing to a pre-release tag npm packages have multiple "current" releases...

pivotallabs.com

...workflow is knowing when assets are delivered from the designer and keeping them in sync with our application as they change. We used to use e-mail, Skype or sticky...

...notes. The trouble is that the designer's file naming and directory structure were never quite the same as the application's /public/images directory, so direct comparisons were impossible and...

In Thunderbird, you can set custom font faces and sizes for reading plain-text e-mails. However, Thunderbird sometimes "randomly" does not respect your choices. This is actually not a...

...some Western (ISO 8859-1), and some maybe yet another encoding. The advanced font settings dialog by default just opens on "Western". Choose a different encoding from the "Fonts for...