- Time spent on mobile vs desktop
- 2015 -> Google started getting more search queries from mobile than desktop
- 2018 -> Time spent on mobile 2-3x bigger than on desktop (and growing...)
- Users reaction
- 46% dislike waiting for slow pages to load
- 53% abandon a site that loads in more than 3 seconds
- As of July 2018, page speed will become an important ranking factor for mobile searches
- Page speed will also influence ad rank and the CPC that you pay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Data < ApplicationRecord | |
class << self | |
def bulk_upsert(values) | |
transaction do | |
values.uniq { |v| v[:key] }.each_slice(1000) do |values_slice| | |
connection.exec_query <<-SQL.squish | |
INSERT INTO #{table_name}(#{upsert_columns.join(', ')}) | |
VALUES #{upsert_values_statement(values_slice)} | |
ON CONFLICT(key) | |
DO UPDATE SET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# taken from https://mrbrdo.wordpress.com/2013/09/25/manually-preloading-associations-in-rails-using-custom-scopessql/ | |
# collection association e.g. has_many | |
owners = People.all | |
association_name = :photos | |
owners.each do |owner| | |
records = Array(whatever_you_want) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mapDuplicates from "./mapDuplicates"; | |
describe("mapDuplicates", () => { | |
it("addresses duplicate surnames", () => { | |
const surnames = ["González", "González", "Martínez", "González"]; | |
expect( | |
mapDuplicates(surnames, (name, index) => `${name} ${index}`) | |
).toEqual(["González 0", "González 1", "Martínez", "González 3"]); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/oblador/react-native-animatable/issues/132#issuecomment-786870602 | |
const MyComponent = (props) => { | |
const ref = React.useRef(); | |
React.useEffect(() => { | |
ref?.current?.fadeIn(); | |
return () => ref?.current?.fadeOut(); // as you know, this is the same as unmount ;) | |
}, [props.id]); // track some prop that changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function nonblock_socket_connect($ip, $port) | |
{ | |
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); | |
if (!socket_set_nonblock($socket)) { | |
socket_error($socket); | |
} | |
$connected = @socket_connect($socket, $ip, $port); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- "master" | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
; #Warn ; Enable warnings to assist with detecting common errors. | |
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
SetScrollLockState, AlwaysOff | |
;following section remaps alt-arrow and command-arrow | |
;keys to mimic OSX behaviour | |
#Up::SendInput {Lctrl down}{Home}{Lctrl up} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# `ERROR: Error installing nokogiri: | |
# ERROR: Failed to build gem native extension. | |
# | |
# current directory: /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.7.0/ext/nokogiri | |
# /usr/local/var/rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170103-68488-r71c9j.rb extconf.rb --with-xml=/usr/local/Cellar/libxml2/ --use-system-libraries | |
# checking if the C compiler accepts ... yes | |
# checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no | |
# Building nokogiri using system libraries. | |
# ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed. | |
# *** extconf.rb failed *** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$counter = 0; | |
$result = preg_replace_callback( | |
'#\?#', | |
function ($match) use (&$counter) { | |
$counter += 1; | |
return $counter; | |
}, | |
'a: ?, b: ?, c: ?, d: ?. e: ?' |