We structure our CSS using the BEM pattern.
Our naming convention for blocks, elements and modifiers has evolved over the years. This card shows our current style and various alternative styles that you might encounter in older projects.
The difference between the various styles are mostly a matter of taste and optics. I do recommend to not mix styles and be consistent within a given project.
Our current BEM naming convention looks...
I experienced a lot of issues with google chrome that made it almost impossible to work with it. Here are some of them:
I finally discovered a setting that fixed these issues for me:
Use system title bar and borders
I'm not sure if this setting was changed by me or if it was the browser default.
CSP hat zum Ziel einen Browser-seitigen Mechanismus zu schaffen um einige Angriffe auf Webseiten zu verhindern, hauptsächlich XSS-Angriffe.
XSS = Cross Site Scripting. Passiert wenn ein User ungefiltertes HTML in die Webseite einfügen kann.
<div class="comment"> Danke für den interessanten Beitrag! <script>alert('you have been hacked')</script> </div>
Rails löst das Problem weitgehend, aber
Ruby's File class has a handy method
binary? which checks whether a file is a binary file. This method might be telling the truth most of the time. But sometimes it doesn't, and that's what causes pain. The method is defined as follows:
# Returns whether or not +file+ is a binary file. Note that this is # not guaranteed to be 100% accurate. It performs a "best guess" based # on a simple test of the first +File.blksize+ characters. # # Example: # # File.binary?('somefile.exe') # => true # File.binary?('somefile.txt') # => fal...
For webpages to load fast it's recommended to optimize images. Ideally an image's file size should be as small as possible while still being of decent quality. This card demonstrates two command line tools for image optimization
identify to fetch information about pictures.
convert can change size/quality and strip meta information. Both commands are supplied by ImageMagick.
$ identify in.jpg in.jpg JPEG 294x440 294x440+0+0 8-bit sRGB 92.8KB 0.000u 0:00.000 $ convert in.jpg -resize x220 -strip -set profile sRGB2014.icc -qua...
One of the many useful features of TextMate is autocompletion of words. If I were in TextMate right now, I could write "au[tab]", and it would complete it to "autocompletion". RubyMine can do this, too. When you write a word (e.g. a variable name), just hit ALT + / repeatedly and it will offer all completions for the letters you typed. This action is called Cyclic Expand Word in RubyMine / IntelliJ IDEA.
This feature keeps you from mistyping variable names, saves you keystrokes and speeds up development. ~10 keystrokes to the price ...
This note is a reminder that there is something called AppArmor that could cause weird errors ("File not found", "Can't open file or directory", ...) after configuration changes, e.g. when changing MySQL's data directory.
Remember to have a look at AppArmor's daemon configuration (usually at
/etc/apparmor.d/) if you change daemon configuration and run into errors such as the one above.
If you want to prevent that two processes run some code at the same time you can use the gem with_advisory_lock.
- The thread will wait indefinitely until the lock is acquired.
- While inside the block, you will exclusively own the advisory lock.
- The lock will be released after your block ends, even if an exception is raised in the block.
This is usually required if there is no suitable database row to lock on.
You want to generate a...
grep is the go-to CLI tool to accomplish tasks like filtering large files for arbitrary keywords. When additional context is needed for search results, you might find yourself adding flags like
-B5 -A10 to your query. Now, every search result covers 16 lines of your bash.
There is another way: You can easily pipe your search results to the VIM editor and cycle through them.
vim -q <(grep -Hn -r "User" .) # vim -q starts vim in the "quickfix" mode. See ":help quickfix" # grep -...
-class @User +class window.User
requirestatement with Webpacker's...
We're pleased to announce Ruby 3’s new language for type signatures, RBS. One of the long-stated goals for Ruby 3 has been to add type checking tooling. After much discussion with Matz and the Ruby committer team, we decided to take the incremental step of adding a foundational type signature language called “RBS,” which will ship with Ruby 3 along with signatures for the stdlib. RBS command line tooling will also ship with Ruby 3, so you can generate signatures for your own Ruby code.
Ruby 3 is coming, and it will have optional type sign...
Ag (aka "the silver searcher") is a very fast replacement for
It will parse your
.gitignore for additional speedup. To ignore even more files (
*.min.js etc), add an
.ignore with syntax identical to
See Faster Grepping in Vim for hints about vim integration.
RSpec 3 has verifying doubles. This breed of mock objects check that any methods being stubbed are present on an instance of a given class. They also check methods aren't called with the wrong number of arguments.
This dual approach allows you to move very quickly and test components in isolation, while
giving you confidence that your doubles are not a complete fiction.
You should always prefer using a verifying double to using an old-...
Extended records now use their own I18n namespace when looking up translations for models or attributes. If the extended record's namespace does not contain a translation, the lookup will fall back to the base record's namespace.
For instance, given the following class hierarchy:
class User < ActiveRecord::Base end class User::Form < ActiveType::Record[User] end
ExtendedParent.human_attribute_name(:foo) would first look up the key in
activerecord.attributes.user/form first, then falls back to `activerecord.attributes...
We're huge fans of Sidekiq for its stability and features. One advantage of GoodJob over Sidekiq is that GoodJob doesn't require Redis. So in cases where you don't have Redis or don't want to pay for a Redis HA quorum node, this might be an alternative worth checking out.
These warnings are printed when the
etc Gem is installed, while
etc is also included in Ruby. Fix with:
gem uninstall etc