See the attached link for a useful overview of modern (and classic) DOM API methods, like
You will still need to look up some documentation, e.g. on how to modify a
ClassList, but it's still better than browsing interfaces and superclasses of
Element on MDN without knowing what to look for.
Subject: performance on smartphones and tablets
I just used your framework in one project and must say,
I am really pleased with it – but only on a desktop computer.
Have you benchm…
Explains the difference betwen
.* (greedy matching) and
.*? (lazy matching), and why the latter can lead to faster patterns.
console.time('myTime'); // Start timer console.timeEnd('myTime'); // End timer and print the time
$nreference the nth-last inspected Element.
Pour color on your Rails console with awesome_print. Turn confusing long strings into formatted output. Have objects and classes laid out clearly whenever you need it.
gem 'awesome_print', :group => :development into your Gemfile. Now on the Rails console you have the command
ap that will give you a colored, formatted output of whatever you pass it. See the example output of the
User class below.
For customization visit the repository on Github.
Bundler 2 requires at least Ruby 2.3.0 and RubyGems 2.5.0. You might get the following error when you try to install
bundler for Ruby < 2.3:
ERROR: Error installing bundler: bundler requires Ruby version >= 2.3.0.
To fix this error upgrade your project's ruby version or install the last supported version of Bundler for Ruby < 2.3:
gem install bundler -v=1.17.3
You will also see an error if your [RubyGems version is < 2.5.0](https://makandracards.com/makandra/61824-rubygems-can-t-find-bundle-executable-although-b…
When you have an element you want to hide, you can add a
ng-show='isOpen' attribute to that element. When you set
false on the scope, the element will be hidden.
However, when you load the page, the element is usually rendered by the browser before Angular has loaded and had a chance to hide it.
ng-cloak directive was designed for exactly this purpose. Add a
ng-cloak attribute or class (and more, see the link) to any element you want to …
Starting from Rails 4.0, you can use a special form options helper called
#collection_check_boxes. It behaves similar to
#collection_select, but instead of a single select field it renders a checkbox and a label for each item in the collection.
= form_for @post do |form| = form.collection_check_boxes :author_ids, Author.all, :id, :name_with_initial
How generated form params look like ———————————…
Carrierwave includes some handy helper methods you can use to resize your images. Here is a quick summary of them, if you need more details read the docs. You can also use all command line options from RMagick directly if these helpers are not good enough for you.
For searching in large database tables we usually use PostgreSQL's fulltext search capabilities.
While this works reasonably well for content primarily consisting of prose, it is not necessarily a good solution for all use cases. The main issue is that it is only possible to search for prefixes of text tokens, which can potentially be unexpected for users.
One example are dates:
If you index the text
2019-01-23 15:16, PostgreSQL will create the following tokens:
2019, -01, -23, 15 16. A user searching for
All Rubyists should be familiar with the common definitions for include and extend. You include a module to add instance methods to a class and extend to add class methods. Unfortunately, this common definition isn’t entirely accurate. It fails to explain why we use instance.extend(Module) to add methods to an instance. Shouldn’t it be instance.include(Module)? To figure this out we’re going to start by discussing where methods are stored.
Capybara will fail to find
<a> tags that are missing an
An example would be an AngularJS application where the following HTML actually works. 
Capybara will fail to find that link, even though looking it up via the DOM shows it:
>> find_link("Hello") Capybara::ElementNotFound: Unable to find link "Hello" >> find("a").text => "Hello"
Spammers have started abusing other application to send their spam. This works like this:
When restoring a PostgreSQL dump using
pg_restore, you usually add the
--clean flag to remove any existing data from tables.
Note that this only removes data from tables that are part of the dump and will not remove any extra tables. You need to do that yourself.
To remove all tables from a database (but keep the database itself), you have two options.
You will need to re-create the schema and its permissions. This is usually good enough for development machines only.
DROP SCHEMA public CASCADE; CREATE SCHEMA public; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO public;
Applications usually use the "public" schema. You may encounter other schema names when working with a (legacy) application's database.
Note that f…
In Rails 3+, you can use:
class Project delegate :url_helpers, to: 'Rails.application.routes' def project_path url_helpers.project_path(self) end end
For Rails 2, use the attached Modularity trait. It will give any Ruby class a method
#url_writer, on which you can call URL helpers:
class Foo does 'write_urls' def self.class_method url_writer.session_path end def instance_method url_writer.project_path(5) end end
sort method doesn't work as expected with German umlauts:
["Schwertner", "Schöler"].sort => ["Schwertner", "Schöler"] # you probably expected ["Schöler", "Schwertner"]
Also numbers in strings will be sorted character by character which you probably don't want:
["1", "2", "11"].sort # => ["1", "11", "2"] # you probably expected ["1", "2", "11"]
Also the sorting is case sensitive:
["a", "B"].sort # => ["B", "a"] # yo...
A great two-part article about various hacks you can use to create great-looking screen designers when you're not a designer.
Part 1 contains:
Part 2 contains: