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...
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...
...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...
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...
...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...
...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 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...
...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...
: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...
...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...
...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...
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.
...browser based test runner. Should be easily adaptable to a pure Webpack setup. Step 1: Install Jasmine yarn add jasmine-core Step 2: Add two separate packs
...s $http service will strip that header when the request data (body) is blank. [1] This is possibly a misconception of RFC2616. Here is how to send GET requests with...
Content-Type:application/json Host:localhost User-Agent:(...) X-Force-Content-Type:application/json Yay. :) [1] The problem is even worse when using Restangular which itself does not even allow passing...
When deploying an application with "cap deploy" by default [1] you only deploy your code but do not run migrations. To avoid an application to be running with code which...
...usage") you should consider hooking them after restart so your application starts up earlier. [1] You may want to consider overwriting the default task to run migrations (instead of update...
cookies = cookies.to_s.split("\n") unless cookies.is_a?(Array) cookies.each do |cookie| name, value = cookie.match(/^([^=]*)=([^;]*);/)[1,2] @cookies[name] = value end This won't work when you there are empty lines...
...exactly what happened for me. That is how my cookie looked when debugging: (rdb:1) puts headers['Set-Cookie'] remember_token=abcdef123456; path=/; expires=Mon, 31-Dec...
positionFields = element.find('input[id$=position]') for position, i in positionFields $(position).val i + 1 Outside of forms, within lists, you may want to manually post the new positions to...
...sortable items (i.e. table rows), which are expected in format _ . For example, tr#position_13 and tr#position_15 will be turned into position[]=13&position[]=15, which neatly resolves...
...column by applying the proper limits (65535 bytes would be a text, up to 16777215 a mediumtext, and up to 4294967295 a longtext). Or if you know that you'll...
create_table 'example' do |t| t.integer :int # int (4 bytes, max 2,147,483,647) t.integer :int1, :limit => 1 # tinyint (1 byte, -128 to 127) t.integer :int2, :limit...
...to read a cookie's value, you need to parse the string: document.cookie.match(/hello=([^;]+)/)[1] // => "universe" Set a cookie Setting cookies works as simple as this: document.cookie = "yes=please"
...for can be set as part of the string: document.cookie = "yes=please; expires=Sun, 1 May 2016 13:37:00 UTC; path=/" Important: If you do not set a path...
...translations on arrival_places.id = arrival_place_translations.place_id AND arrival_place_translations.locale = "en"') .order('departure_place_translations.name, arrival_place_translations.name') .where(ride_id: 1) .paginate(page: 1, per_page: 20) .preload( departure_place: :translations, arrival_place: :translations )
...cluster locale settings: psql -p 5435 ^ postgres=# SHOW LC_COLLATE; lc_collate ------------- en_US.UTF-8 (1 row) postgres=# SHOW LC_CTYPE; lc_ctype ------------- en_US.UTF-8 (1 row) You may also list...
...removed and another one added. $ git diff diff --git a/app/models/content_migration/photo.rb b/app/models/content_migration/photo.rb deleted file mode 100644 index fea2bca..0000000 --- a/app/models/content_migration/photo.rb +++ /dev/null @@ -1,42 +0,0 @@ -class ContentMigration::Photo < ActiveRecord::Base # ... # ...
...git a/app/models/content_migration/record/photo.rb b/app/models/content_migration/record/photo.rb new file mode 100644 index 0000000..2c8b70a --- /dev/null +++ b/app/models/content_migration/record/photo.rb @@ -0,0 +1,42 @@ +class ContentMigration::Record::Photo < ActiveRecord::Base # ... After: The diff shows that a file has...