stackoverflow.com

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:

...with a nice way to grep through your project's files: The finder (ctrl + shift + f). Don't be discouraged about the notice 100+ matches in n+ files if your...

...searched keyword is too general or widely used in your project. RubyMine comes with a few ways to narrow down the resulting list, don't hesitate to apply those filters...

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...

With passenger-status --show=requests you can get a huge JSON showing current information about the running passenger processes. This can be useful if you want to find out what...

...a passenger process is doing at the moment (for e.g. if one worker seems to be stuck): * PID: 4273 Sessions: 1 Processed: 47 Uptime: 50m 53s CPU: 43% Memory : 3644M...

github.com

...default it allows only accessing visible elements -- when you are using a driver that supports it (e.g. Selenium, not the default Rack::Test driver). Consider the following HTML: One

...true) or find(..., visible: :visible). Note that you could change the default behavior by setting the ignore_hidden_elements config option. However, ignoring invisible elements is a useful default.

...just barely wider than the container it should fit into, and it wraps a single word to a new line and it's not really pretty? Cry no more, for...

...in some browsers. When browsers encounter a text-wrapping element with text-wrap: balance style, they will try breaking to a new line sooner, if it balances out the width...

GoodJob and ActiveJob rescue exceptions internally, preventing exception_notification from triggering. This can cause silent job failures.To get notified, subscribe to ActiveJob events and configure GoodJob's on_thread_error...

...job failures, as they are handled internally by ActiveJob/GoodJob. ActiveSupport::Notifications.subscribe(/(enqueue_retry|retry_stopped|discard)\.active_job/) do |event_name, *, payload| exception = payload[:error] job = payload[:job]

Modern CSS offers the field-sizing property to allow elements to automatically adjust size (width and/or height) to fit their contents. The most common use case are textareas which start...

...fairly small (e.g. 2 or 3 rows tall) but grow when users enter longer text. Usage textarea { field-sizing: content; } That's it! At least in modern Chromium-based browsers...

...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...

We're always striving towards keeping our website's JavaScript as small as possible. If you're using webpack(er), you can use the webpack-bundle-analyzer plugin to get...

...a good overview, which of your JavaScript modules take up how much space, and where you can optimize. To use it, add it via npm or yarn yarn add webpack...

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...

makandracards.com

...bug) and want to use git bisect to find out when it was introduced? Smart kid. If you have a shell command ready to reveal if your current state is...

...other hand will use the return value of that call to decide if the state is good or bad. First, start bisecting git bisect start Then tell git which revisions...

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...

makandra Operations
baeldung.com

...measurement metrics in Linux. These are the differences: Code Name Description vsz virtual memory size Total amount of memory a process may hypothetically access. Includes swapped memory, memory from external...

...libraries and allocated memory that’s not used. rss resident set size Total amount of non-swapped used physical memory. Includes memory from external shared libraries. pss proportional share size...

...the commit which was deployed. If you want to know the currently deployed release, simply SSH to a server and view that file. $ cat /var/www/my-project/current/REVISION cf8734ece3938fc67262ad5e0d4336f820689307 Capistrano task

...application is deployed to multiple servers, you probably want to see a result for all of them. Here is a Capistrano task that checks all servers with the :app role...

developer.mozilla.org

You can do so much more than console.log(...)! See the attached link for a great breakdown of what the developer console can give you. Some of my favorites: console.log takes...

E.g. console.log("Current string:", string, "Current number:", 12) Your output can have hyperlinks to Javascript objects E.g. console.log("Check out the current %o, it's great", location)

github.com

Capybara-screenshot can automatically save screenshots and the HTML for failed Capybara tests in Cucumber, RSpec or Minitest. Requires Capybara-Webkit, Selenium or poltergeist for making screenshots. Screenshots are saved...

...into $APPLICATION_ROOT/tmp/capybara. Manually saving a page Additionally you can trigger the same behavior manually from the test using Capybara::Session#save_and_open_page and Capybara::Session#save_screenshot...

makandra dev

Geordi provides a pretty neat way to generate beautiful commit messages according to your stories in Linear: geordi commit Geordi reads from a .geordi.yml file inside your repo and connects...

...to Linear to list started and finished stories with their title. Choosing one of them generates a commit message including id and title from Linear app and a link to...

When you have an Angular directive that transcludes content, you might want to do something in case there is no content inside your element, like showing some default content.

...you can not do something like default goes here . Angular will always empty that element's text, even if there is nothing to transclude. But you can use your directive...

Jasmine has long standing support for writing asynchronous specs. In days gone by we used the done callback to achieve this, but these days it is possible to write much...

...more readable specs. Async specs As a first example, say we want to check that some form disables the submit button while working. // bad (how we used to do it...

When your Rails application server raises error, Capybara will fail your test when it clears the session after the last step. The effect is a test that passes all steps...

...behavior will help you to detect and fix errors in your application code. However, sometimes your application will explode with an error outside your control. Two examples: A JavaScript library...

makandra dev
rubydoc.info

CarrierWave comes with some RSpec matchers which will make testing more comfortable. Let's say you have an Uploader like this: class MyUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick

...different versions of your uploaded files: version :small do process resize_to_fill: [100, 100] end version :medium do process resize_to_fit: [200, nil] end version :large do

makandra dev

...or ::1 (IPv6) can only be reached from your own PC: Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process tcp LISTEN...

...address 0.0.0.0 can be reached from other PCs on your network: Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process tcp LISTEN...