postgresql.org

...is pretty useful, but manipulating values of arrays can be awkward because of its syntax. Consider the following users table which each example below will start from: name topics

Bob {llamas} (PostgreSQL uses curly braces to represent arrays, true story.) Adding values Use the array_cat function, or the || operator. These calls will add the values "cats...

makandra dev
github.com

...written in pure Ruby and integrates with Rails applications. It provides features as automatic sizing of dots and lines (the more values, the thinner the graph's elements), custom or...

...predefined themes, different styles (bar, line, dot and many more) and multiple graphs in one chart. Installation In your Gemfile: gem 'rmagick', :require => false gem 'gruff' Then run bundle install...

...entering only http://example.com/). If you want to make a request to that site's web server without actually talking to www.example.com (e.g. because this is a load balancer...

...s address but you want to access one specific machine), you cannot just request machine1.example.com or localhost as the above vhost will redirect your request. When talking HTTP 1.1, your...

Ruby's standard library includes a class for creating temporary directories. Similar to Tempfile it creates a unique directory name. Note: You need to use a block or take care...

...of the cleanup manually You can create a prefix and suffix e.g. Dir.mktmpdir(['foo', 'bar']) => /tmp/foo20220912-14561-3g93n1bar You can choose a different base directory than Dir.tmpdir e.g. Dir.mktmpdir('foo', Rails.root.join('tmp...

When using the asset pipeline your assets (images, javascripts, stylesheets, fonts) live in folders inside app: app/assets/fonts app/assets/images app/assets/javascripts app/assets/stylesheets With the asset pipeline, you can use the...

When you deploy, Rails runs assets:precompile which precompiles all assets into static files that live in public/assets. This way you have all the performance of static files...

How to ignore new files Globally Add the path(s) to your file(s) which you would like to ignore...

can’t find executable rails for rails-3.2.3 (Gem::Exception) ... one of several...

...things might be wrong. You're using RVM It's possible that you have a system-wide gem executable (like rails) that requires a gem that is not available in...

makandra Curriculum

...we use pagination Exercises Create 7500 movies in MovieDB (hint: Doing it in a single transaction is much faster). Load the movies index and measure how long it renders.

...the movies index render now? Inspect the HTML generated by will_paginate. Customize the style so it matches the look of your MovieDB. tail -f log/development.log and see which queries...

ActiveRecord provides the ids method to pluck ids from a scope, but what if you need to pluck Global IDs? While you could just call map(&:to_global_id) on...

...your scope, this approach would instantiate each record just to do that. When you have many records, this will at the very least be slow. Here is a method that...

On your local system that only hosts non-critical development data and only you have access to, you can store MySQL's root password in your home directory so you...

...out of the question if there's any confidential data in your databases. Assuming diligent screen-locking, an encrypted hard disk and correct permissions set on your credential file, it...

Middleman is a static page generator that brings many of the goodies that Rails developers are used to. Out of the box, Middleman brings Haml, Sass, helpers etc. However, it...

...these gems to the Gemfile: group :test do gem 'cucumber' gem 'spreewald' gem 'capybara' gem 'selenium-webdriver' # Only for running tests in a real browser (suggested) gem 'capybara-screenshot' # Optionally...

ActionMailer per default uses http as protocol, which enables SSL-stripping. When a logged-in user follows an http link to your application, it sends the cookies along with it...

...to send emails from public parts of your application with HTTP links and emails from SSL-protected parts with HTTPS, build a before_filter. If you need certain links with...

Our CI setup frequently sees this error while running yarn install: yarn install v1.22.19 [1/4] Resolving packages... [2/4] Fetching packages... error An unexpected error occurred: "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz: unexpected end...

...here are some workarounds for Yarn 1. Increase Yarn's network timeout yarn config set network-timeout 600000 -g Retry yarn install until it succeeds The following will retry yarn...

Git allows you to set push options when pushing a branch to the remote. You can use this to build an alias that automatically pushes a branch and creates a...

...merge request for it. Put this in your ~/.gitconfig in the [alias] section: mr = push origin HEAD -o merge_request.create -o merge_request.draft Now you can do git mr and a draft...

smashingmagazine.com

A comprehensive introduction to sending HTML emails. Intro: HTML email: Two words that, when combined, brings tears to a developer’s eyes. If you’re a web developer, it’s...

...in your career, whether you like it or not. Coding HTML email is old school. Think back to 1999, when we called ourselves “webmasters” and used Frontpage, WYSIWYG editors and...

Spreewald's patiently repeats the given block again and again until it either passes or times out. Be careful to give patiently a block that can actually be repeated. E.g...

...the field variable that was defined outside of the block (it's the variable set from the Given block's arguments). Because of this, during the first repetition the value...

stackoverflow.com

...run rake and your code is causing an exception which is not the one shown in your terminal. Rails tries to catch this exception and clean up constants but -- while...

...it's still booting up -- fails on this which causes another exception: rake aborted! cannot remove Object::ClassMethods Running rake with the --trace parameter will give you no love; the...

thoughtbot.github.io

Let's say you have two factories that share some attributes and traits: FactoryBot.define do factory :user do screen_name 'john' email 'foo@bar.de' trait :with_profile do age 18 description...

age 18 description 'lorem ipsum' end end end You can re-use the shared fields by defining a trait outside the other factory definitions: FactoryBot.define do trait :person do...

These are the results of the "personal tech stack survey". I've included only the most popular mentions, maybe it can help you find one or two useful tools for...

...Command line UI for git. htop (10 users) An improved "top". fzf (8 users) Provides super-fast fuzzy-finding in various contexts (for example for shell command history).

Capistrano automatically logs each (successful) deployment into a file on your application servers. It is located at the root of your server's project folder, i.e. the parent of releases...

...and current, like so: /var/www/your-project$ ls current log releases repo revisions.log <--- here shared Each line in that file contains the deployed branch, commit, release ID, and username (was read from...

...you, like a browser would (e.g. move block elements out of parents which are specified to not allow them). >> Nokogiri::HTML.fragment(" foo bar ").to_s => " foo bar "

...HTML. And you don't want to be the one to blame when the SEO folks complain about an empty . To avoid said behavior, use Nokogiri::XML instead of Nokogiri...

Having a unique selector for an element is useful to later select it from JavaScript or to update a fragment with an Unpoly. Haml lets you use square brackets ([]) to...

...with ActiveRecord instances, which have a persisted #id and will hence generate the same selector over multiple renderings of the same view. Example - @users.each do |user| .row[user] = user.name

makandra dev

...the transcluded content before adding it to the DOM. # Directive template: """ """ transclude: true link: (scope, element, attributes, _controller, transclude) -> transclude (content) -> # Do custom stuff element.find('.wrapper').append(content)

...much more you can do with the transclusion function. For an in-depth introduction, see this Guide to Angular Transclusion. Also read the Angular docs on this...

news.ycombinator.com

This is an extract from the linked article. It shows an approach on how to implement encrypted passwords with the AWS Key Management Service (KMS). For most applications it's...

...enough to use a hashed password with a salt (e.g. the gem devise defaults to this). Upon password creation Generate hash as hash of password + salt. Encrypt the hash with...