...syntax is a bit different. UnderscoreJS In UnderscoreJS, methods always return a value: x = [1, 2, 2] _.uniq(x) // => [1, 2] _(x).uniq() // => [1, 2] If you want to chain...

...call value() to terminate the chain. _.chain(x).uniq().map(function(i) { return i + 10 }).reverse().value() // => [12, 11] LoDash In LoDash, methods called from _ (like _.uniq) will behave as...

...your magic here end end Example structure The resulting directory structure will be: /app-root/public/system/users/avatar/000/001/... (1st record) /app-root/public/system/users/avatar/000/002/... (2nd record) ... /app-root/public/system/users/avatar/000/999/... (999th record) /app-root/public/system/users/avatar/001/000/... (1000th record) ... /app-root/public/system/users/avatar/999/999/... (999'999th record) /app-root/public/system/users/avatar/1000/000...

...1 millionth record) So if you have 500k records, you will still only have 500 directories inside /app-root/public/users/avatar/. And inside each of them, at most 1000 sub-directories.

...queries (simplified; the number at the beginning of each line is the connection ID): 1 Connect 1 BEGIN 1 INSERT INTO foos 1 Quit 2 Connect 2 SELECT COUNT(*) FROM...

BANK_CODE = /\A\d{8}\z/ # Germany BANK_ACCOUNT_NUMBER = /\A\d{1,10}\z/ # Germany ZIP_CODE = /\A\d{5}\z/ # Germany HEX_COLOR = /\A([a-fA-F0...

IP_ADDRESS = /\A(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)(?:\.(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)){3}\z...

...can cause the above error, when the arc cosine of something slightly more than 1.0 is to be computed, e.g. for the (zero) distance between the same coordinates (applies only...

...fix, we just force the value we compute the arc cosine of into [-1; 1] bounds. Put this into a config/initializers/graticule_spherical_distance.rb initializer: Graticule::Distance::Spherical.class_eval do def self.distance(from...

...middleware yourself. Here is an example that limits concurrency of the "mailers" queue to 1. It uses a database mutex via the with_advisory_lock gem but you could easily...

...rand(4)}" (not perfect, but might be good enough). For rate-limiting (e.g. only 1 job per 5 seconds) you could name it "mailers-throttle-#{(Time.now.to_i / 5.0).to_i...

...You still need to include rome/dist/rome.css for its basic positioning styles. rome(element, { weekStart: 1, // Monday weekdayFormat: 'short', // Mon styles: { // Picker overlay container: 'rd-container border rounded-lg shadow bg...

...a makandra card?") }; let cardsPathPattern = /(\/[\w-]+\/\d+)-.+/; if (window.location.pathname.match(cardsPathPattern)) { let currentPath = window.location.pathname.match(cardsPathPattern)[1]; let title = document.querySelector('h1.note--title')?.textContent; if (title) { prompt("Your markdown link:", `[${title}](${currentPath})`);

Typhoeus has a different way of representing array params in a get request than RestClient. Typhoeus: http://example.com/?foo[0]=1&foo[1]=2&foo[2]=3

makandra dev

Trick: Do not use convert but mogrify: mogrify -resize 50% * This overwrites the original image file. In contrast, convert writes...

...circle, it is then asked to compute the arc cosine of a result like 1.0000000001. Since this is undefined, MySQL correctly returns NULL (instead of the expected distance of...

...this problem is to discard rounding errors by forcing any results into bounds [-1; 1] before computing the arc cosine on it. Put the following into an initializer like config/initializers/graticule_spherical_to_sql_without_nulls.rb...

We forked trusty memoizer to make two changes: Memoized methods now preserve their arity. Previously all memoized methods had an...

...you should still remove them after you're done. Here are three options: Option 1: Using a block it 'does something with a temporary directory' do Dir.mktmpdir('exports') do |export...

...event listener with { once: true }: up.on('up:fragment:inserted', { once: true }, function () {...

In Unpoly 1 you can immediately unregister the listener with up.off: up.on('up:fragment:inserted', function fragmentInsertedCallback() {

makandra dev

...was not detected in the system." $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" exit 1 end end Deploying again should now install the missing dependencies as expected...

...unexpectedly splat the array elements: block = proc { |a, b| "a=#{a}, b=#{b}" } block.call(1, 2) # "a=1, b=2" block.call([1, 2]) # "a=1, b=2" Note that lambdas...

...behave as expected: block = lambda { |a, b| "a=#{a}, b=#{b}" } block.call(1, 2) # "a=1, b=2" block.call([1, 2]) # ArgumentError: wrong number of arguments (1 for...

makandra dev

...Let's say you split User into the traits "authentication" and "permissions". In Modularity 1 you now had to say: class User < ActiveRecord::Base does 'user/authentication' does 'user/permissions' end

Automatically migrate a project to Modularity 2 If you have been using Modularity 1 with the does syntax, the Modularity 2 gem provides a script to migrate your Ruby...

github.com

...always cached prior to actually storing it (to support form roundtrips). Carrierwave by default 1) copies the file to the cache and then 2) copies it again to its final...

Icon font: little CPU load (no JavaScript) fonts are relatively large 1 extra HTTP request Javascript + inline SVG: higher CPU load (needs to watch the DOM via...

no extra HTTP requests SVG sprites: largest file size, hard to subset 1 extra HTTP request In practice there are probably additional performance tradeoffs. Luckily, there is a...

...projects, :analytic_stats, :jsonb) Project.reset_column_information Project.find_each do |project| project.analytic_stats = { version: 1, analytics_url: nil, clicks_this_week: 0, clicks_this_month: 0, clicks_this_year...

...ApplicationRecord validate :validate_analytic_stats_against_json_schema has_defaults( analytic_stats: proc { { version: 1, analytics_url: nil, clicks_this_week: 0, clicks_this_month: 0, clicks_this_year...

...application, you can use these few lines of CoffeeScript code: joinSentence = (array) -> if array.length > 1 array[0..-2].join(', ') + ', and ' + array[-1..] else array.join ', ' Examples: > joinSentence(['cats', 'dogs', 'pandas'])

...Here is some plain JavaScript, should you prefer that: function joinSentence(array) { if (array.length > 1) { return array.slice(0, -1).join(', ') + ', and ' + array.slice(-1); } else { return array.join...

makandra dev

...threads. Unfortunately, when you use blocking system calls (e.g. locks on the database), Ruby 1.8 threads won't work because system calls will block the whole interpreter. Luckily you can...

...ActiveRecord::Base.establish_connection(config) end it 'should synchronize processes on the same lock' do (1..20).each do |i| fork_with_new_connection do @reader.close ActiveRecord::Base.connection.reconnect! Lock.acquire('lock') do...

makandra dev
innig.net

...closure-like entities? "return" returns from closure True closure? or declaring context...? Arity check? --------------- ----------------------------- ------------------- 1. block (called with yield) N declaring no 2. block (&b => f(&b) => yield) N declaring...

...Y except return declaring warn on too few 5. proc <<< alias for lambda in 1.8, Proc.new in 1.9 >>> 6. lambda Y closure yes, except arity 1 7. method Y closure...

:T_MODULE=>44, :T_FLOAT=>4, :T_STRING=>65685, :T_REGEXP=>137, :T_ARRAY=>984, :T_HASH=>87, :T_STRUCT=>12, :T_BIGNUM=>2,

:T_COMPLEX=>1, :T_SYMBOL=>29, :T_IMEMO=>5008, :T_ICLASS=>49} Look out for a number that keeps growing over time. Rails In a Rails application...