Observed on Rails 2.3 and machinist 1.0.6 Like the title says, when you define the method empty? like in the following example, you may not longer use collection.make.

...has_many :pages def empty? pages.empty? end end Assuming b1 = Book.find(1) b2 = Book.find(2) instead of expected b1.pages.make #=> #<Page id: 1, book_id: 1> b2.pages.make #=> #<Page id: 2, book...

...a vertical output. You know this: mysql> SELECT * FROM users; +----+---------+---------------------+-----------------+ | id | name | email | greeting | +----+---------+---------------------+-----------------+ | 1 | Alice | alice@example.com | Hello world! | | 2 | Bob | bob@example.com | Hello universe! | | 3 | Charlie | charlie@example.com | Hi mom...

This is how it looks like vertically: mysql> SELECT * FROM users \G *************************** 1. row *************************** id: 1 name: Alice email: alice@example.com greeting: Hello world! *************************** 2. row *************************** id: 2

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

...you could then test it like this: get :index persisted_session[:page_views].should == 1 # session[:page_views] is 1, so that would still work get :index persisted_session[:page...

...views].should == 2 # session[:page_views] would be 1, even though it works in the real world

...of objects, uniq does not work as expected, since it uses strict equality. So [[1], [1]].uniq() == [[1], [1]] In some cases, this might be a workaround: [[1], [1]].invoke...

...toJSON").uniq().invoke("evalJSON")

...total is either memoized itself, or using some # private memoized method subject.seat_counts = [5, 1] subject.seat_total.reload.should == 6 # => Still 5 end You might be tempted to manually unmemoize any memoized internal...

...fiddling with internal state. When writing tests, stay on your chosen abstraction level. Solution 1 record.unmemoize_all Solution 2 Perform a full reload by re-finding your record:

marvin.soup.io

...this problem when you update your FreeBSD Ports: ===>>> Launching child to update ruby19-iconv-1.9.3.547,1 to ruby20-iconv-2.0.0.576,1 ===>>> All >> ruby19-iconv-1.9.3.547,1 (17/17) ===>>> Currently installed version...

...ruby19-iconv-1.9.3.547,1 ===>>> Port directory: /usr/ports/converters/ruby-iconv ===>>> This port is marked IGNORE ===>>> Not needed with Ruby 2.0 or newer ===>>> If you are sure you can build it, remove the IGNORE...

...occurs in sliders with HTML content. The issue When a slider contains a composited[1] element, the element will overlap any other element when sliding, being rendered as frontmost element...

...or fully, e.g. by using z-index) B is rendered in its own layer[1] C is moved with a CSS transition the transition moves A and B in from...

...array for e.g. one level, it takes an optional argument. # Flattens the array recursively >> [1, [2, [3]]].flatten => [1, 2, 3] # Flattens the array the given number of times

makandra dev

...bin/spring stop pkill -f spring To prevent Spring from starting again: export DISABLE_SPRING=1

...sed -E 's/:[0-9]+: .*//'`" line_number="`echo $line | sed -E 's/.*:([0-9]+).*/\1/'`" else file="`echo $line | sed -r 's/:[0-9]+: .*//'`" line_number="`echo $line | sed -r...

...s/.*:([0-9]+).*/\1/'`" fi # since $file in working directory isn't always equal to $file in index, # we backup it; thereby we can add our whitespace fixes without accidently...

...some CSS selectors: function floatIn($element) { $element.css({ 'opacity': 0, 'margin-top': 200px }); $element.animate({ 'opacity': 1, 'margin-top': 0 }, { duration: 500 }); } The animation is implemented using setInterval and Javascript. This works...

...as smooth as a CSS transition. Fortunately the animate API can be mapped almost 1:1 to CSS transitions. There are libraries like Transit that act as a drop-in...

makandra dev
semaphoreci.com

...used anywhere inside the Rake tasks. See #Resources at the bottom for examples. Step 1: Upgrade guide For migration from 2 to 3, follow this tutorial: Capistrano 3 Upgrade Guide...

Use the new syntax instead: set :ssh_options, {...

wrong number of arguments (1 for 2) undefined method `tail' for nil:NilClass You need to wrap your task body...

ls -1tr * | tail -1 Used switches The -1 switch makes ls return 1 file per line, -t orders by modification time and -r causes sorting from oldest to...

...you care about performance, never use a query like UPDATE users SET has_message = 1 WHERE users.id IN (SELECT user_id FROM messages) MySQL does not optimize this and seems...

UPDATE users INNER JOIN messages ON messages.user_id = users.id SET has_message = 1 or pipe it through ruby with something like user_ids = ActiveRecord::Base.connection.select_values(Message.select(:user...

...zone name by doing time_object.zone. This zone is considered when doing time calculations, e.g. 10 AM CEST minus 8 AM UTC is zero. A datetime in MySQL does not have...

...a zone. It just stores the literal string "2010-05-01 12:00:00". That means that Rails must make assumptions about timestamps loaded from and written to MySQL.

Boot partitions from installations prior to the 16.04 era are terribly small. When you install updates and encounter errors due to a full /boot partition, consider risizing it.

...the steps described below, ask someone experienced to help you out. This has worked 100% so far. 1 out of 1 tries. ;) Scenario A: There is unassigned space on your...

...increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment | +-------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ | test1 | MyISAM | 10 | Dynamic | 3 | 121...

...NULL | utf8_general_ci | NULL | | | | attachments | InnoDB | 10 | Compact | 0 | 0 | 16384 | 0 | 16384 | 3145728 | 1 | 2011-08-17 13:46:48 | NULL | NULL | utf8_general_ci | NULL | | | +-------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+

uri = URI('http://example.com/?foo=1&bar=2') stub_request(:get, 'example.com').with(query: {foo: 1, bar: 2}) Net::HTTP.get(uri) # ===> Success If you only want to check if foo is...

...uri = URI('http://example.com/?foo=1&bar=2') stub_request(:get, 'example.com').with(query: hash_including(foo: 1)) Net::HTTP.get(uri) # ===> Error hash_including doesn't parse query values to string, you need...

Use the PDF toolkit: sudo apt-get install pdftk To rotate page 1 by 90 degrees clockwise: pdftk in.pdf cat 1E output out.pdf # old pdftk pdftk in.pdf cat 1east output...

...out.pdf # new pdftk To rotate all pages clockwise: pdftk in.pdf cat 1-endE output out.pdf # old pdftk pdftk in.pdf cat 1-endeast output out.pdf # new pdftk The E (old pdftk...

...Let's say you have this $scope in your Angular controller: $scope.tasks = [ { 'text': 'Task 1' }, { 'text': 'Task 2' } ] And you have this template: {{task.text}} Which renders this HTML:

...bound to the second you can say this in jQuery: var li = $('li:eq(1)'); li.scope().node // => { 'text': 'Task 2' } Or if you'd like to access the entire list...

...query of three random words from the same vocabulary. I used sample sizes from 1,000 to 100,000 records, meaning 50,000 to 5,000,000 indexed words.

...more efficient than I thought For a medium-sized data set of up to 10,000 records (500,000 words) or so, LIKE only takes a fraction of a second...

commandlinefu.com

...helpful when watching them but, since they are ANSI color codes like ^[[4;36;1m, can be annoying when you are reading the logs with a tool that does just...

Remove them with sed: cat staging.log | sed -r "s/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" This will print the log without colors...

codepen.io

position: absolute; top: 0; bottom: 0; } .section::before { left: calc(50% - 50vw); right: 100%; } .section::after { left: 100%; right: calc(50% - 50vw); } Here is how we place the ::before...

...the viewport width and end up at the very left of the window. right: 100% means that the right side of ::before ends at the left of .section.