Learn to treat files as an ActiveRecord attribute type, like :string or :integer Research Look at the README for the carrierwave gem Read about Common mistakes when storing file...
...the form where we can also fill in title, year, etc. On the movie show view, render a poster version that is 400 pixel wide, with a height that respects...
...in the context of our application. While you could roll out a custom authentication solution, this would likely expose you to the various risks of "homegrown crypto". In practice we...
...like clearance or devise for this task. Learn Read the article Rails Authentication from Scratch You don't need to do write any code, but you should be able to...
When you're using feature branches, they will stack up if you don't delete them after the merge to master. Here's how to tidy them up. Delete feature...
...Find already-merged branches by running # On branch master git branch --merged You may safely delete each of the listed branches, because they point to commits that are contained in...
Are My Indexes Affected? If your database has been created on an operating system with glibc version < 2.28 and later upgraded to an operating system with glibc >= 2.28, you...
...affected. To find out which indexes in our database are affected, run the following slightly modified query from the PostgreSQL documentation: CREATE extension amcheck; SELECT bt_index_check(index => c.oid...
...tough challenge. To get more detailed insights consider using the rack-mini-profiler gem. Setup with Unpoly Add the following gems: group :development do gem 'memory_profiler' gem 'rack-mini...
If you have slow views (Haml/Partials can be slow), consider caching them. Remove code & sql-queries that are not needed to render the page. Calling to_a blindly on...
Intel CPUs receive updates, including security relevant upgrades, through 2 channels: Firmware/UEFI BIOS updates can also update the microcode in CPUs. This is the preferred and persistent way
How to install an microcode update? If one is available and deemed sufficiently stable from Debian's or Ubuntu's perspective, the intel-microcode package is updated and...
If you want to switch to another ruby versions, you have several options, depending on what you want: Do you want to switch temporarily, per project, or globally?
Unlike RVM, rbenv does not offer a command like rvm use. By default, it respects your project's .ruby-version file. If you need to change manually...
...good thing. It's possible to configure this requirement at the web- or proxy server level, where nginx or apache will just redirect every request on http to https. Some...
...if the URL they've been called with contains the http or the https scheme and issue their own redirect response (usually 301 or 302) to https. This card is...
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...
While it might seem trivial to implement an invoice that sums up items and shows net, gross and vat totals, it actually involves a lot of rules and caveats. It...
...examples in Ruby and MySQL, the concepts apply to all programming languages and data stores. When to round There are exactly two spots where your invoice logic should round money...
Du weißt was copy-on-write ist und warum das in Zusammenhang mit Snapshots praktisch ist Du weißt was Fragmentierung ist und wann und wo es bedeutsam ist
Du weißt wie du einen Datenträger verschlüsselst Du weißt wie man ein Linux System verschlüsselt Du weißt wie man die Systeme jeweils wieder entschlüsselt Inhalte LinuxFilesystemsExplained (Achtung alt)
...upgrade tasks according to its actual value. Consider to create and periodically maintain a summary, which helps you and your team in the decision which refactoring task should be taken...
Estimated Efforts Visible customer value Customer value explained Developer value Developer value explained Short title for the task Score from 0-5 Score from 0-5 Explanation
...posts; if you use pagination the queries will be more complicated, but the point still stands. Looks harmless enough? It is not. The problem ActiveRecord will rewrite this into a...
...query using LEFT JOINs which looks something like this: SELECT "blog_posts".*, "comments".*, "attachments".* FROM "blog_posts" LEFT OUTER JOIN "comments" ON "comments"."blog_post_id" = "blog_posts"."id"
When you use method_missing to have an object return something on a method call, always make sure you also redefine respond_to_missing?. If you don't do it...
def method_missing(method_name, *args, &block) if method_name == :bark 'woof!' else super end end end This will allow you to say: Dog.new.bark => "woof!" But: Dog.new.respond_to? :bark...
Since I use this a lot in my daily work and there were no scripts working properly for me, I made one myself. It's actually not bound to Xfce...
...t tried it, though). Installation If you don't yet have xdotool, install it: sudo apt-get install xdotool If you don't yet have wmctrl, install it:
...a global variable in Rails? Ugh, that's the worst. If you need global state, you've probably reached for Thread.current. When you're using Thread.current, you must make sure...
...yourself or your cached data will stay in Thread.current. For Sidekiq, you can use request_store-sidekiq. Cronjobs are unaffected, as a new process is created each time...
You can change which branches will be pushed when saying git push. Our recommendation is to set it to current. From the git-config documentation: push.default Defines the action git...
...branch, but forgot to setup tracking. If you can't currently push, use git branch --set-upstream-to=origin/$(git branch --show-current...
Systemd's networkd will drop IP-Addresses configured by other processes like Keepalived's VRRP, when it is restarted. This may happen on updates. To prevent this following settings are...
...critical: yes to /etc/netplan/50-cloud-init.yaml eth1: addresses: - 192.0.2.67/24 gateway4: 192.0.2.1 nameservers: addresses: - 198.51.100.42 - 198.51.100.53 search: - example.lcal critical: yes run netplan generate This will add the CriticalConnection to your networkd configuration...
...block evaluates to true. first_post_with_image = posts.find do |post| post.image end However, sometimes it's not the item you're interested in, but some value depening on it...
...image).find(&:present?).url If the mapping is a costly operation or has undesirable side effects, you need to do it in a single iteration instead. Single iteration solution with...
If you need to convert an SVG source to PS or EPS, the most common suggestion on the interwebs is to use Inkscape from the commandline. Inkscape is a fairly...
...converting is CairoSVG. CairoSVG is available on most Linux distros through their package management systems, e.g. apt install cairosvg on Ubuntu. It has few dependencies (most importantly Python 3 and...
...to read the The framework field guide - Fundamentals, the first of a three part series to learn the basics of frontend technologies. I can highly suggest it for learning the...
...fundamentals. 'The framework field guide' is written by Unicron Utterances and there side has many high quality articles on web development and computer science related to programming. The Framework Field...
Here are a few common patterns that will probably lead to flaky specs. If you notice them in your specs, please make sure that you have not introduced a flaky...
Using RSpec matchers One rule of thumb I try to follow in capybara tests is using capybara matchers and not plain rspec matchers. One example: visit(some_page)
...und bedienen im DevOps- & Cloud-Bereich primär Kunden, die ebenfalls auf Linux als Ziel-System setzen. Entsprechend benötigen wir tiefgehendes Wissen über Linux. In diesem Kapitel lernst Du alles zum...
...Hintergrund und ein wenig Theorie zu Prozessen, Speicher, Konfiguration und viel praktisches zur Konfiguration, Ressourcenüberwachung und abschließend eine Anleitung zur Performance-Analyse von Unix-basierten Systemen in 60 Sekunden.
Why string sorting sucks in vanilla Ruby Ruby's sort method doesn't work as expected with special characters (like 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...