View
Deprecated

How to disable material design in Google Chrome

A few releases back, Chrome started using a Material Design UI on desktop. If you don't like it (on some window managers or GTK themes it's ugly), you can disable it.

  1. Visit chrome://flags/
  2. Search (Ctrl+F) for "Material Design"
  3. Switch to "Non-Material"
  4. Restart Chrome

Chrome's default theme should now be pretty again.

Isolate Side Effects in Ruby

In this article, we’ll look at what side effects are, why they are problematic despite being necessary, and how to isolate them to minimise their drawbacks.

External content

How to tidy up your Git mess

Git is hard: screwing up is easy, and figuring out how to fix your mistakes is fucking impossible. Git documentation has this chicken and egg problem where you can't search for how to get yourself out of a mess, unless you already know the name of the thing you need to know about in order to fix your problem.

So here are some bad situations I've gotten myself into, and how I eventually got myself out of them in plain english*.

Maybe this flowchart may be of help…

Repeats

Collect all values for a given column in an ActiveRecord scope

The Edge Rider gem allows you to collect an array of values for one field of your ActiveRecord elements:

>> User.active.collect_column(:id)
=> [1, 5, 23, 42]

It also comes with a :distinct option in case you are only interested in unique values:

>> Article.collect_column(:state, distinct: true)
=> ['draft', 'published']

In modern Railses (since 3.2) you can also use ActiveRecord's pluck met…

Capistrano: exclude custom bundle groups for production deploy

Capistrano is by default configured to exclude the gems of the groups development and test when deploying to the stages production and staging. Whenever you create custom groups in your Gemfile, make sure to exclude these, if they should not be deployed to the servers. The gems of these groups might not be loaded by rails, however, the deployment process will take longer as the gems will be downloaded and installed to the server.

e.g. to exclude the groups cucumber and deploy, add the following to `config/deploy/production.rb…

Git: how to work with submodules

Sometimes you might need to nest a git-project inside another git-project. The right strategy is to use submodules in this case.

Add a submodule

Here is how you add a nested project inside your parent project

$ git submodule add <nested-repository-url>

git status will now show you the following:

new file:   .gitmodules
new file:   nested_project

nested_project will point to the specific git commit of the nested project.

Clone a project with submodule

New team members can check out the the parent project and th…

Hack of the day: One-liner to run all changed Cucumber features

Similar to our snippet that runs all Cucumber features matching a given string, the following will run all modified or new Cucumber features by looking at your git status:

git status --short | grep -v '^ D ' | grep '.feature' | sed 's/.. //' | tr '\n' ' ' | xargs geordi cucumber

If you want to know what each of the above commands does, see [explainshell](http://explainshell.com/explain?cmd=git+status+–short+%7C+grep+-v+%27%5E+D+%27+%7C+grep+%27.feature%27+%7C+sed+%27s%2F..+%2F%2F%27+%7C+tr+%27%5Cn%27+%27+%27+%7C…

Minidusen: Low-tech record filtering with LIKE queries

We have a new gem Minidusen which extracts Dusen's query parsing and LIKE query functionality.

Minidusen can no longer index text in MySQL FULLTEXT columns, which was hardly used and didn't always help performance due to the cost of reindexing.

Minidusen is currently compatible with MySQL, PostgreSQL, Rails 3.2, Rails 4.2 and Rails 5.0.

Basic Usage

Our example will be a simple address book:

```ruby
class Contact < ActiveRecord::Base
validates_presence_of :name, :street, :city, :e…

Javascript: Read params from url

There is no build in functionally in jQuery and Prototype to extract params from a url.

  1. You can use this library (not tested): jquery-deparam

  2. Use Unpoly and the following code snippet

Repeats

Javascript: Compare two arrays for equality

Don't Google this, you will lose all will to live. Instead use Object#isEqual from Underscore.js:

_.isEqual([1, 2], [2, 3]) // => false
External content

ClockPicker: Android-style time picker for Bootstrap

ClockPicker is a JavaScript and Bootstrap implementation of an Android-style time picker which looks and feels great.

Unfortunately, it is no longer maintained.

ClockPicker.png

External content

Quill - Your powerful, rich text editor

A new open source WYSIWYG editor that promises superior fidelity and customizability.

This might be a future alternative to Redaktor.

Also see SlateJS and Trix.

How to use Haml in your helpers

You know those helper methods that just render some HTML but look weird because of content_tags all over the place? You could also use Haml instead.

Example

Consider the following helper.

def greeting
  message = ''.html_safe
  message << 'Welcome to '
  message << content_tag(:span, Rails.env, class: 'greeting--location')
  content_tag :div, message, class: 'greeting'
end

That looks clumsy and is hard to read.

Wouldn't it be nicer to say something like this?

def greeting
  render_haml <<-HAML
 ...

We are no longer maintaining Dusen

If you were using Dusen for its query parsing and LIKE queries, we recommend to migrate to Minidusen, which extracts those parts from Dusen. Minidusen is compatible with MySQL, PostgreSQL and Rails 3.2, 4.2 and 5.0.

If you are looking for a full text indexing solution, we recommend to use PostgreSQL with pg_search.

Geordi 1.5.1 released

  • Improve geordi cucumber: Only attempt @solo run when the specified files contain the @solo tag, skip @solo run if any filename is passed with a line number (e.g. features/example.feature:3)
  • Improve geordi deploy: Find stages by their prefix (e.g. s -> staging, m -> makandra), bundle if needed, check the selected stage exists
  • Improve geordi server: Takes port as argument (e.g. geordi ser 3001), option --public (-P) starts the server with -b 0.0.0.0 to make it accessible from other machines in the local network, e.g. …
Repeats

Git: Revert a commit

Reverting a commit means creating a new commit that undoes the old changes.

git revert commit_sha1

Using Spring and parallel_tests in your Rails application

You want Spring for super-fast binstubs like bin/rails or bin/rspec which avoid Rails boot time.
You want parallel_tests to speed up full test runs of large test suites.

Unfortunately, you do not want parallel_tests to use your Spring binstubs as those parallelized tests will share data and/or loose some information. There are some issues about this on GitHub and there is a suggested [workaround](https:…

External contentRepeats

SVGO: SVG Optimizer

SVG files are often much larger than necessary, containing comments, metadata, hidden elements etc.

Optimize them with this tool.

View
3248 cards