themomorohoax.com

A global h2 style probably isn’t going to last more than a month before everyone starts changing it inline...

...than it should, this expression requires 4 attempts to match the string: Attempt Group $1 Group $2 Expression result 1 "aaabbb" not matched not matched 2 "aaabb" not matched

...bbb)/ only requires a single attempt to match "aaabbb": "aaabbb" =~ /^(a+)(bbb)/ Attempt Group $1 Group $2 Expression result 1 "aaa" "bbb" matched! Because greedy quantifiers start backtracking when an...

@email = email @newsletter = newsletter end end User.new( 'Mr.', 'John', 'Doe', 'Potsdamer Platz 1', '10117', 'Berlin', '+49 0151 1122334455', 'john.doe@example.com', true ) Using keyword arguments Using keyword arguments is easier...

salutation: 'Mr.', first_name: 'John', last_name: 'Doe', street_and_number: 'Potsdamer Platz 1', zip_code: '10117', city: 'Berlin', phone_number: '+49 0151 1122334455', email: 'john.doe@example.com', newsletter: true )

mysqlperformanceblog.com

...foo@example.com'; +----+-------------+-------+-------+----------------------+----------------------+---------+-------+------+-------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+----------------------+----------------------+---------+-------+------+-------+ | 1 | SIMPLE | users | const | index_users_on_email | index_users_on_email | 768 | const | 1 | | +----+-------------+-------+-------+----------------------+----------------------+---------+-------+------+-------+

...data types. Like integers for string fields: mysql> EXPLAIN SELECT * FROM users WHERE email = 12345; +----+-------------+-------+------+----------------------+------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+----------------------+------+---------+------+--------+-------------+

...options = Selenium::WebDriver::Chrome::Options.new options.add_argument('--disable-infobars') options.add_emulation(device_metrics: { width: 1280, height: 960, touch: false }) unless ENV.key?('NO_HEADLESS') options.add_argument('--headless') options.add_argument('--disable-gpu...

...app, browser: :chrome, options: options) end Selenium::WebDriver.logger.level = :error Headless Chrome in legacy Capybara 1 projects If you're working on a legacy project with Capybara version 1.x, the...

...opening a form, JavaScript makes a request to acquire a lock for that record (1). After 20 seconds the JavaScript starts polling the server (2), to check if another user...

When the PC was low on resources (parallel_tests), acquiring the lock (1) took so long that the client starts polling for updates (2) before the initial lock...

...You might think that the following queries yield the same result: User.where(movie_ids: [16, 17]) User.where(movie_ids: [17, 16]) Turn's out - they are not! They do care...

...the where_array_matches method below. Note that it does not care about duplicates - [1, 2, 2] is handled identically to [1, 2]: # lib/ext/active_record/relation.rb class ActiveRecord::Relation def where_array...

makandra dev

...can globally disable animations like this: up.motion.config.enabled = false Disabling animations in AngularJS In AngularJS 1.x you can globally disable animations like this: angular.module('myApp', []).run(['$animate', function($animate) { $animate.enabled...

...AJAX, I've found it helpful to limit the number of concurrent requests to 1. This will implicit serialize UI interactions that make an AJAX request. You can configure Unpoly...

makandra dev

...be using this example tree (from the acts_as_nested_set docs): root | +-- Child 1 | | | +-- Child 1.1 | | | +-- Child 1.2 | +-- Child 2 | +-- Child 2.1 | +-- Child 2.2 Option 1: Parent Association

This would serialize the example above to this table: id | parent_id | data ---+-----------+---------- 1 | NULL | root 2 | 1 | Child 1 3 | 2 | Child 1.1 4 | 2 | Child 1.2...

echo "> Deleting remote branch ..." git push origin --delete $merged_branch_name exit 1 else echo "x Did not delete the \"$merged_branch_name\" branch." fi

...the branch deleted: $ git merge ds/foo Updating 338e82e38..2d4269c81 Fast-forward foo | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 foo > You have just merged the...

...the copied invoice and the creation of its items. This list of changes (e.g. 12 INSERT statements) will be committed in a single atomic operation, or not at all. This...

...order, you might get a deadlock. For instance, transaction A wants to change row #1 and row #2. Transaction B wants to change the same rows, but in different order...

...NULL values with the + value. The sum value will be NULL. MySQL: mysql> select 1 + 2 + 3; +-----------+ | 1 + 2 + 3 | +-----------+ | 6 | +-----------+ 1 row in set (0,00 sec)

+--------------+ | 1 + NULL + 3 | +--------------+ | NULL | +--------------+ 1 row in set (0,00 sec) Postgres: test_database=# select 1 + 2 + 3; ?column? ---------- 6 (1 row) test_database=# select 1 + NULL...

...contained values. If your project uses Lodash or Underscore.js, you can use _.isEqual(): _.isEqual([1, 2], [2, 3]) // => false _.isEqual([1, 2], [1, 2]) // => true If your project already uses...

...Unpoly you may also use up.util.isEqual() in the same way: up.util.isEqual([1, 2], [2, 3]) // => false up.util.isEqual([1, 2], [1, 2]) // => true If you are writing server-side code in...

...the net total is calculated from the gross total: gross = items.sum(&:total) vat = (gross * (1 - (1 / VAT_RATE))).round(2) net = gross - vat Don't show VAT amounts for individual...

end create_table :items do |t| t.integer :invoice_id t.decimal :unit_price, :precision => 10, :scale => 2 t.integer :quantity t.timestamps end Note how we are using a DECIMAL column rather...

...Rails do the logic # Good User.where.not(id: []).to_sql => SELECT "users".* FROM "users" WHERE (1=1) User.where.not(id: [1]).to_sql => SELECT "users".* FROM "users" WHERE ("users"."id" != 1) User.where.not...

...id: [1, 2]).to_sql => SELECT "users".* FROM "users" WHERE "users"."id" NOT IN (1, 2) Rails < 4 Before Rails 4, you needed to work around this yourself: # Good excluded_ids.blank...

...into errors like this: I18n::InvalidPluralizationData: translation data {...

...} can not be used with :count => 1. key 'one' is missing. They seem to appear out of the blue and the error...

...the user attribute, but the user model! Now it invokes the translation with count: 1. I18n tries to pluralize the derived key (i.e. the user model, and fails. Instead of...

...for all environments by adjusting your config/database.yml: default: &default adapter: postgresql # ... variables: statement_timeout: 10s # or ms, min, etc Test that it works: ActiveRecord::Base.connection.execute("show statement_timeout;").map { |row...

=> [{"statement_timeout"=>"10s"}] begin ActiveRecord::Base.connection.execute("SELECT pg_sleep(15)") rescue ActiveRecord::QueryCanceled => e Rails.logger.error("Query was canceled: #{e.message}") end Adjust or disable the timeout for a single transaction...

...may cause the relation to select more records than expected: authorized_users = User.where(id: [1, 2]) filtered_users = User.where(id: [2, 3]) authorized_users.merge(filtered_users).to_sql # => SELECT * FROM users...

...merged relation select the users (2, 3), although we are only allowed to see (1, 2). The merged result should be (2). This card explores various workarounds to combine two...

...Here is an example where this diff is helpful while comparing two hashes: {a:1}.should match(a:1, b:2) Failure/Error: {a:1}.should match(a:1, b...

...expected {:a=>1} to match {:a=>1, :b=>2} Diff: @@ -1,3 +1,2 @@ :a => 1, -:b => 2, Unfortunately, this diff is not as clever as it would need to...

...Rails 5 does not halt callback chain if false is returned Legacy Rails versions (1-4) Goal Rails version Within before_* Within after_* Cancel later callbacks Rails 1-4

return false Rollback the transaction Rails 1-4 return false raise ActiveRecord::Rollback Take care that your callbacks don't accidentally return false, since that cancels the chain in...

...PLAN ------------------------------------------------------------------------------------------------------------------------------- Seq Scan on users (cost=0.00..332518.66 rows=343223 width=422) (actual time=143.706..61621.403 rows=213865 loops=1) Filter: (search_text ~~* '%max%'::text) Rows Removed by Filter...

...true, Deforming true Timing: Generation 5.688 ms, Inlining 0.000 ms, Optimization 8.882 ms, Emission 132.362 ms, Total 146.931 ms Execution Time: 61856.303 ms (9 rows) With a GIN index

...like seconds, minutes, etc. Example usage >> new Duration(42).humanized() => '42 Sekunden' >> new Duration(123456).humanized() => '1 Tag' >> new Duration(123456).humanized('es') => '1 día' Code Here is the code...

...this.years = this.days / 365 } humanized(locale = 'de') { const humanizer = new Duration.Humanizer(locale) if (this.minutes < 1) { return humanizer.humanize(this.seconds, 'second') } else if (this.hours < 1) { return humanizer.humanize(this.minutes, 'minute') } else if (this.days < 1...

sgruendel.blogspot.com

When you install Type 1 fonts (like makandra's corporate typeface), they won't show up in OpenOffice. OpenOffice requires some additional files to process them. Stefan Gründel found out...