<input type="file"> accepts a single file. You can allow multiple files via
<input type="file" multiple>.
But sometimes, selecting multiple files is not enough and can be cumbersome for the user. Enter
<input type="file" webkitdirectory multiple>
webkitdirectory switches the browser's file picker to select a directory. All files inside that directory, and inside any nested subdirectories, will be selected for the file input.
This can be useful when users want to upload all files from a nested dire...
Versions 2.9.0, 2.99.0 and 3.0.0 of our gem Spreewald have been released.
an email should have been sent with:does now support wildcards (
*at the end of a line to ignore the rest of the line,
*as single character in a line to ignore multiple lines). The step also has better error messages if an email could not be found.
show me the emailsgot an option to display only the email headers. Additionally, a new step `show me the email( header)?s...
If you want to get the path of a file relative to another, you can use the
expand_path method with either the constant
__FILE__ or the method
__dir__. Read this card for more information about
. ├── bin │ ├── format_changelog ├── CHANGELOG.md
#!/usr/bin/env ruby changelog_path = ? # How to get the path to ../CHANGELOG.md independent of the working dir of the caller changelog = File.read(changelog_path) # ... further actions h...
Git commits should be very deliberate, and only contain changes that you really want to be in there. In order to reduce the chance to accidentally commit something you didn't intend, review your changes before committing.
git add -N . # Add all paths, but not their contents git add -p
Git will now show you all your changes in small chunks and ask you in an interactive mode whether you really want to add them.
The most helpful commands are
Note: Modern Rails has two build pipelines, the asset pipeline (or "Sprockets") and Webpacker. The principles below apply for both, but the examples shown are for Sprockets.
CSS variables are very different from preprocessor variables. While preprocessors use variables to compile a static piece of CSS, CSS custom properties are a reactive (i.e. live) part of the styles. Think of them like usual CSS properties that cascade, but have:
A flat folder structure can be cool if you have only a few folders but can be painful for huge amounts. We recently had this issue in a project with more than 100.000 attachments, where we used a structure like this
ls command lasted several minutes to show us the content of the attachments folder.
So we decided to use a more hierarchical structure with a limited maximum of folder per layer. As our attachment folder will grow very fast we choosed to use three layers, but that's up to you. Here...
When you use Sentry to monitor exceptions, an important feature is Sentry's error grouping mechanism. This will aggregate similar error "events" into one issue, so you can track and monitor it more easily. Grouping is especially important when you try to silence certain errors.
It is worth understanding how Sentry's grouping mechanism works.
The exact algorithm has changed over time, and Sentry will keep using the algorithm that was active when you created the proj...
In Ruby on Rails, all the routes of a given application can be found within the config/routes.rb file.
You add more and more routes in this file as your project grows.
The problem here is that this file potentially becomes very complicated to manage over the time.
That’s why it’s important to find a way to order and maintain your routes.
routes.rb grows very fast and each line adds mo...
When writing some logs to a file, that don't use Ruby's logger utility, it is often useful to sync them. So other process can read the output just in time.
log_path = '/tmp/some_log.log' log_file = File.open(log_path, 'a+') log_file.sync = true log_file.puts('Some log message') File.read(log_path) #=> "Some log message\n" log_file.puts('Some other message') File.read(log_path) #=> "Some log message\nSome other message\n"
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...
-class @User +class window.User
requirestatement with Webpacker's...
This guide shows how to create an AngularJS application that consumes more and more memory until, eventually, the browser process crashes on your users.
Shift + ESCto see a list of Chrome processes...
Most forms have a single submit button that will save the record when pressed.
Sometimes a form needs additional submit buttons like "accept" or "reject". Such buttons usually attempt a state transition while updating the record.
To process a form with multiple buttons, your server-side code will need to know which button was pressed. To do so you can give each submit button a different
[formaction] attribute. This will override the ...
Open-source software (OSS) is great. Anyone can use virtually any open-source code in their projects.
Well, it depends. Licenses can make things difficult, especially when you are developing closed-source software. Since some OSS licenses even require the employing application to be open-sourced as well (looking at you, GPL), you cannot use such software in a closed-source project.
To be sure on this, we have developed a project-level integration of Pivotal's excellent [license_finder](https://g...
Test Driven Development is the paradigm to "first write a test, then implement the code". This guide shows how to apply it in practice, with Cucumber and RSpec as integration and unit test frameworks.
I like to view TDD as a process with three levels:
During development you are frequently changing levels. It may look something like this:
Integration _ _ Code \__ ___ __/ Spec \____/ \__...