makandra Curriculum

...offers an 8 month paid trainee program 🇩🇪 for junior developers that are looking to start a professional career in web development. This curriculum contains goals, resources and code exercises for...

...When an exercise asks you to do multiple versions, these should be reviewable as separate commits or branches. After the review with mentor you can keep the best version and...

...signal("mouse::enter", function(c) local focused = client.focus if focused and focused.class == c.class and focused.instance == "sun-awt-X11-XDialogPeer" and c.instance == "sun-awt-X11-XFramePeer" then return end if awful.layout.get...

...change that one). Known issues This will not affect "find anything" as IntelliJ uses a sun-awt-X11-XFramePeer for it. There are no properties which allow distinguishing the "find...

Sometimes you accidentally generate entries in the bash history that you do not want to have there (e.g. commands with credentials). Here's how to remove single entries.

...look at the bash history with the history command. To see e.g. the last 5 entries, use history | tail -n 5: >history | tail -n 5 1994 my-secret-command...

makandra dev
select2.org

Select2 comes with AJAX support built in, using jQuery's AJAX methods. ... For remote data sources only, Select2 does not create a new element until the item has been selected...

query: params.term, page: params.page || 1 } } processResults: function (data, params) { return data }, } }); Further reading: https://select2.org/data-sources/ajax

...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. Example with enabled sync...

File.read(log_path) #=> "Some log message\nSome other message\n" Example with disabled sync (default) log_path = '/tmp/some_log.log' log_file = File.open(log_path, 'a+') log_file.puts('Some log message')

...truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. This will cause horrible, data-destroying bugs...

...this reason you should probably not use GROUP_CONCAT ever. At least you must set the value of group_concat_max_len to an insanely high value on every database...

makandra dev

gem install ruby-debug (Ruby 1.8) or gem install debugger (Ruby 1.9) Start your server with script/server --debugger Set a breakpoint by invoking debugger anywhere in your code...

...path that crosses the breakpoint Once you reach the breakpoint, the page loading will seem to "hang". Switch to the shell you started the server with. That shell will be...

...pattern below. The module pattern gives you basic class concepts like a constructor, private state, public methods. Since the module pattern only uses basic JavaScript, your code will run in...

...that we want to translate into Javascript using the module pattern. It's a simple class with one private function: # Ruby class Dog def initialize(name) @name = name

If you need to capture signatures on an IPad or similar device, you can use Thomas J Bradley's excellent Signature Pad plugin for jQuery. To implement, just follow the...

...steps on the Github page. The form If you have a model Signature with name: string, signature: text, you can use it with regular rails form like this:

...CSS but it does not fit fancy requirements. Here is a hack for the special case where you want to truncate one of two strings in one line that can...

...both vary in length, while fully keeping one of them. See this example screenshot where we never want to show an ellipsis for the distance: You can try pretty hard...

...have a useful blank? method. It returns true for nil but also for empty strings or empty arrays. There is also a universal method present? which returns true for all...

...may also use up.util.isBlank(). By default, this function returns true for: undefined null Empty strings Empty arrays A plain object without own enumerable properties All other arguments return false.

Microsoft Exchange service administrators can enable Exchange Web Services (EWS) which is a rather accessible XML API for interacting with Exchange. This allows you to read and send e-mails...

...meeting attendees, track responses, manage to-do tasks, check user availability and all other sorts of things that are usually only accessible from Outlook. You can implement an EWS by...

.../.bashrc to have it always available. Adjust to your needs. Usage $> tab_title # title set to the current directory's name $> tab_title new_title # title set to "new_title...

...Auto-setting the title If you want your title to update each time you change the working directory, put this code after the function definition. # auto-title cd() { builtin cd...

Sometimes, you may want to open up a second database connection, to a read slave or another database. When doing that, you must make sure you don't overwrite an...

...will actually cause all kinds of trouble: def with_other_database ActiveRecord::Base.establish_connection(slave_settings) yield ensure ActiveRecord::Base.establish_connection(master_settings) end Putting aside that you are setting...

Sometimes you need to monitor a connection from your machine to a specific, single host or network in order to identify which network hop between your machine and the target...

...causes trouble. You can use the following shell script to easily achieve this kind of monitoring. If the target host is unable to respond to the specified number of ICMP...

...did not happen yet you should use cap deploy:migrations. The problem Let's say that you have something like that in your config/deploy.rb to create a database dump every...

...called for cap deploy:migrations. The same applies to other things that are hooked similarly, like an after 'deploy', 'craken:install'. How to avoid it When looking at the default...

Let's say you want to merge the properties of two JavaScript objects: let a = { foo: 1, bar: 2 } let b = { bar: 3, baz: 4 } let merged = merge(a, b...

...foo: 1, bar: 3, baz: 4 } Depending on your build, there are several ways to implement merge(). When you have ES6 When you have an ES6 transpiler or don't...

...are close to given coordinates you can use the Graticule gem. Graticule Graticule offers several methods to compute the distance between two geo-dated objects but fetching records from the...

...radius of a location is a bit trickier: def close_destinations(latitude, longitude) distance_sql = Graticule::Distance::Spherical.to_sql(:latitude => latitude, :longitude => longitude, :units => :kilometers) Destination.all(:conditions => [ "#{distance_sql...

When you click a link or a press a button on a Selenium-controlled browser, the call will return control to your test before the next page is loaded. This...

...can lead to concurrency issues when a Cucumber step involves a Selenium action and a Ruby call which both change the same resources. Take the following step which signs in...

ariejan.net

...you create columns in a migration. Its meaning depends on the column type, and sometimes the supplied value. The documentation states that :limit sets the column length to the number...

...of characters for string and text columns, and to the number of bytes for binary and integer columns. Using it This is nice since you may want a bigint column...

...in: days) to import, while I actually just wanted to have the full database structure with some data to use on my development machine. After trying several suggestions on how...

...to speed up slow MySQL dump imports (which did not result in any significant improvement), I chose to import just some rows per table to suffice my needs. Since editing...

We recently decided to put static content for HouseTrip.com to Amazon Cloudfront for a faster user experience. This happens fully automatically on deploy and is transparent in development. Together with...

...a heavy use of sprites this sped up page load time quite nicely. These are a couple of the problems you need to solve in order to do this:

If - for whatever reason - you have to render stylesheets dynamically, the following snippet might be of help. It emulates what "sprockets" would to when precompiling your assets, and give your...

...stylesheets access to all the regular bells and whistles (like asset_path, proper @imports etc): class DynamicStylesheetsController < ApplicationController def show logical_path = RELATIVE_PATH_TO_YOUR_TEMPLATE path = File.join(Rails.root...

...class for the presenter instead of extending objects DCI-style. This allows them to add statically-defined callbacks and validations from ActiveModel with the syntax that we know and love...

...question: We should be clear about why a form model is a better place for screen-specific code than a plain old controller. Weren't controllers originally the place for...