Follow the instructions here. PRs at makandra/rubocop-config are welcome. Also check the issue tracker. RubyMine Since version 2017-1 RubyMine...

github.com

From Ubuntu 17, rbenv fails to install Ruby below 2.4 because of a mismatching OpenSSL dependency: it needs libssl1.0-dev for the installation process, but recent Ubuntus come with libssl-dev...

...instead of the current upstream version (which is 7). Install Ruby like this: # Ruby 1.8.7 apt install libssl1.0-dev # This will remove libssl-dev CONFIGURE_OPTS="--with-readline-dir=/usr/include/readline --with...

...With a block, it counts the number of elements yielding a truthy value. ary = [1, 2, 4, 2] ary.count #=> 4 ary.count(2) #=> 2 ary.count { |x| x...

The following snippet will convert a string with wildcards to a appropriate regexp, i.e. parse_wildcards("foobar") # => /\Afoo.bar\z/

execute "SET @pos := 0;" update " UPDATE pages SET position = ( SELECT @pos := @pos + 1 ) ORDER BY updated_at DESC...

...due to a conflict, for example), you may want to know the current commit. [1]\ Luckily, there is lots of useful stuff in the .git directory. Commit hash that you...

...Handy when you want to look at that branch's state of the file. [1] While git shows the commit when stopping at conflicts, for example, that information may have...

When your block takes an argument that should have an default, only in Ruby 1.9 you can say: block = lambda do |message, options = {}| # ... end If you are on Ruby 1.8.6...

...or 1.8.7 you must resort to the following workaround: block = lambda do |*args| message = args[0] options = args[1] || {}

makandra dev

...to a variable and further want to use it. Example: irb(main):001:0> 1 + 2 => 3 irb(main):002:0> _ => 3 irb(main):003:0> a...

jimneath.org

...and many more you'll need when reading weird code. Regex $~ (last MatchData) $1 $2 $3 $4 (match groups from the last pattern match) $& (last matched string) $+ (last match...

...weekdays (Monday to Friday) between to given dates, try this: require 'date' a = Date.parse "11.04.2014" b = Date.parse "31.12.2014" (a..b).count {|date| (1..5).include?(date.wday...

makandra dev
magnus-g.github.io

...invert the pattern. @include texture(green, 34, 0); // color, texture-number, 0=inverted or 1=normal If you have ever done this manually you know how much pain this can...

...list all branches matching your query as input options for git checkout greckout ar 1) ar/cache-api-keys-1098 2) ar/add-categories-object-to-tv-show-1382...

...Import the icon-font by adding a file icon_font.sass: $icon-prefix: '-' @import "generated/icon_font_icons" $size: 1em * $line-height-base // only works with bootstrap .icon // adjust some styles display: inline-block

height: 1em font-size: $size -moz-osx-font-smoothing: grayscale -webkit-font-smoothing: antialiased text-rendering: auto font-style: normal font-weight: normal line-height: 1 // We can not...

unixetc.co.uk

When a directory has more than a few thousand entries, ls will start taking really long to list its content...

I've encountered a Ubuntu 16.04 today, where localhost resolved to ::1 instead of 127.0.0.1. This will not usually make a difference, but could be relevant for firewall policies...

makandra dev
github.com

...from your current database state. The generated db/seeds.rb will look this: Product.create!([ { category_id: 1, description: "Long Sleeve Shirt", name: "Long Sleeve Shirt" }, { category_id: 3, description: "Plain White Tee...

...Shirt", name: "Plain T-Shirt" } ]) User.create!([ { password: "123456", username: "test_1" }, { password: "234567", username: "test...

cyberciti.biz

...the environment variable PIPESTATUS So you can just echo ${PIPESTATUS[@]} to get them all. 13:52:30 ✔ claus:~$ ps ax | grep /usr/bin/ruby 13205 pts/20 S+ 0:00 grep --color=auto...

13:52:43 ✔ claus:~$ echo ${PIPESTATUS[@]} 0 0 PIPESTATUS is an array, so you can get the exitcode of an specific command (first pipe): 13:54:20 ✔ claus:~$ echo...

tldp.org

...to a certain maximum, you can just compare against the modulus of that maximum + 1. \ For example, the following will yield results between 0 and 9: echo $(($RANDOM % 10...

...echo $(($RANDOM % 10)) 9 Note that this skews random numbers to the lower regions of your boundaries in most cases...

makandra dev

Dir.glob(File.join RAILS_ROOT, 'app', 'models', '*.rb').collect{ |path| path[/.+\/(.+).rb/,1] }.collect(&:camelize).collect(&:constantize...

Note: The behaviour of Spreewald's within step is as described below for version < 1.9.0; For Spreewald >= 1.9.0 it is as described in Solution 1. When doing integration testing with...

# Feature When I pick "Lions" from the album picker within ".media-picker-1" # Step definition When /^I pick "(.+?)" from the album picker$/ do |label|

...# open the picker and...

apidock.com

...an integer and want to use it to represent an element's position (like "1st" for 1, or "2nd" for 2), you can use ActiveSupport's ordinalize: 1.ordinalize # => "1st"

1002.ordinalize # => "1002nd" 1003.ordinalize # => "1003rd" -11.ordinalize # => "-11th" -1001.ordinalize # => "-1001st...

stackoverflow.com

...regexp !~ string) The Ruby 2.4 method Regexp#match? does not set globals like $~ or $1, so it should be more performant...

trackduck.com

Service that you can integrate for user feedback. Super-simple integration: Add a tag to your layout, done. It will then add a button to the bottom right of your application. When a user clicks it, they can take a screenshot and leave a message. The screenshot then appears in TrackDuck's interface for you to work off. Current pricing is 9 USD per month for the smallest tier (1 project).

vimeo.com

Hashrocket Lunch n' Learn #1 with Avdi Grimm: Making Little Classes out of Big Ones A look at the pros and cons of four different techniques for breaking a too...