I had some problems with Git and the file spec/fixtures/ČeskýÁČĎÉĚÍŇÓŘŠŤÚŮÝŽáčďéěíňóřšťúůýž. After pulling the latest commits, it would show that file as untracked, but adding and committing it would throw...
...unicode fixture file once again' did not match any file(s) known to git. Solution Install Git version > 1.8.2 using homebrew and set git config --global core.precomposeunicode true Done.
When building a form with a file select field, you may want to offer your users a live preview before they upload the file to the server. HTML5 via jQuery...
...Luckily, HTML5 has simple support for this. Just create an object URL and set it on an tag's src attribute: $('img').attr('src', URL.createObjectURL(this.files[0])) Unpoly Compiler
There are several ways to merge two (or more) PDF files to a single file using the Linux command line. If you're looking for graphical tools to edit or...
...annotate a PDF, we have a separate card for that. PDFtk (recommended) PDFtk is a great toolkit for manipulating PDF documents. You may need to install it first (sudo apt...
...context) is run outside of transactions, so data created here will bleed into other specs before(:example) is run before each spec inside it, Generally, you'll want a clean...
...setup for each spec so that they are independent of other specs in the same context. Example Consider this spec: describe User, 'something' do before :context do @user = User.make
...that happens on your local machine Manually remove the offending's gem files and specifications. The paths will be something like /usr/lib/ruby/gems/1.8/gems/your-broken-gem and /usr/lib/ruby/gems/1.8/specifications/your-broken-gem Update Rubygems or Slimgems by running...
...gem update --system Run bundler on your project to reinstall the offending gem. If this happens to your during deployment Ask your operations team to do it. After the update...
Ubuntu has a package mysql-sandbox that lets you install multiple MySQL versions into your user home: Install mysql-sandbox sudo apt install mysql-sandbox Download the version of MySQL...
...you want to use from mysql.com: https://dev.mysql.com/downloads/file/?id=480427 Make sure to choose "Generic Linux" instead of "Ubuntu" so you get a .tar.gz instead of .deb cd into the directory...
...run our end-to-end tests with headless Chrome. While it's a very stable solution overall, we sometimes see the headless Chrome process freeze (or the Capybara driver losing...
...connection, we're not sure). The effect is that your test suite suddenly stops progressing without an error. You will eventually see an error after a long timeout but until...
This post is not about devops, it's not about lean startups, it's not about web scale, it's not about the cloud, and it's not about continuous...
...nested projects. Then it's really helpful! This makes use of the CDPATH variable. Similar to the PATH variable, which holds the list of directories which are searched for executables...
Then add the following to your ~/.bashrc: export CDPATH=.:~/.bookmarks/ function mark { ln -sr "$(pwd)" ~/.bookmarks/"$1" } # Always resolve symbolic links (e.g. for bookmarks) alias cd="cd -P"
When using custom properties in your stylesheets, you may want to set a specific property value to an existing variable in your SASS environment. A pratical example would be a...
...existing quotes, you may use the meta.inspect() function: @use "sass:meta" $my-cool-font: "Roboto", sans-serif :root --font-family-sans-serif: #{meta.inspect($my-cool-font)} Unfortunately, the output of...
Let's say you have two XML strings that are ordered differently but you don't care about the order of attributes inside containers: a = ' batman secret ' b = ' secret batman...
...Working with plain string comparison is not helpful, of course: a == b => false Instead, you can use the Nori gem to convert your XML into a hash: xml_parser = Nori.new...
...take a long time, so we only want to compile when needed. This card shows what will cause Webpacker (the Rails/Webpack integration) to compile your assets. When you run a...
While development it is recommended to boot a webpack dev server using bin/webpack-dev-server. The dev server compiles once when booted. When you access your page on localhost before...
When you set both a record's association and that association's foreign key attribute, Rails does not realize you are talking about the same thing. The association change will...
...win in the next save, even if the foreign key attribute was changed after the association. As an example, assume you have these two models: class Group < ActiveRecord::Base
fake_stripe spins up a local server that acts like Stripe’s and also serves a fake version of Stripe.js, Stripe’s JavaScript library that allows you to collect your...
...customers’ payment information without ever having it touch your servers. It spins up when you run your feature specs, so that you can test your purchase flow without hitting Stripe...
...clean out the database before each example. Use :transaction where possible. Use :deletion for Selenium features or when you have a lot of MyISAM tables. Understanding database cleaning
...to clean out your test database after each test, so the next test can start from a blank database. To do so you have three options: Wrap each test in...
...needed a way to make my apps full screen from bash scripts. There is no super-easy way, but it's not too hard either. Put the attached script into...
...e.g. /usr/local/bin and make it executable. Now you can call fullscreen Safari and Safari will go full screen. Notes This script needs activated access for assisting devices. Turn it on...
...can be especially painful when external code (read: gems) uses const_defined? to look something up and gets different results on different Rubies. Consider this: module Foo FOO = 42
end On Ruby 1.8, Bar won't have FOO defined as a constant since that's (even though it's accessible): 1.8.7 > Foo.const_defined? :FOO => true 1.8.7 > Bar.const_defined...
We use CarrierWave in many of our projects to store and serve files of various formats - mostly images. A common use case of CarrierWave's DSL is to "process" the...
...versions", for example different resolutions of the same image. Now we could go one step further: What if we want to create versions that have a different file extension than...
...capistrano_colors' end It's possible you need to do a bundle update net-ssh to get things running. Now double check that all your custom hooks are actually still...
...called. One candidate might be an after deploy:symlink hook that has been renamed into after deploy:create_symlink. I also suggest to put a safeguard into your deploy.rb that...
...and a damaged reputation. Deploy Ruby with confidence knowing you're using the most secure, enterprise-grade builds for the platforms that power your business. You'll get priority access...
...fail-safe Ruby for business applications, but don't require advanced features like indemnification or site-wide licensing. Business Edition customers trust ActiveState's guaranteed technical support and regular fixes...
...association. For example you can put the blank form on top with the following snippet: actors = movie.actors actors.build actors.unshift(actors.pop(1)) # won't work with Rails 4+ Because build_for...
...one-to-many association collection object you only have to reorder the collection objects. Sorting with Rails 3+ = form.fields_for :children, @parent.children.sort_by(&:name) do |fieldsform...
...OPTS="--no-tcmalloc" rbenv install, but that would disable tcmalloc. Doing that, you might still encounter issues with ossl_ssl.c -- which is where I switched to the patched solution above...
...without_callbacks. There is no such thing in vanilla Rails 3. There is a gem sneaky-save that restores the missing functionality with a #sneaky_save method...
String#indent is not a standard Ruby method. When you use it, be sure to know where this method comes from. Many Gems shamelessly define this method for internal usage...
...and you'll never know when it may be removed (since it's usually not part of the Gem's API). Unless you're using Rails 4 (which brings String...