...A-Za-z0-9]+> is easier to write but matches invalid tags such as <1>. Use \b[1-9][0-9]{3}\b to match a number between 1000 and...
...Use \b[1-9][0-9]{2,4}\b matches a number between 100 and 99999. Modes: Greedy, Lazy and Possessive Example string: This test is a first test string...
...the constructor. returnValue & returnValues it('shuffles the array', () => { spyOn(Random, 'shuffle').and.returnValue([3, 2, 1]) array = [1, 2, 3] testedClass = new testedClass(array) expect(Random.shuffle).toHaveBeenCalled() expect(testedClass.array).toEqual...
}) If you have several new classes created in one test you could also use returnValues for any call of the method Random.shuffle. callFake If you are testing the class...
...the moment (for e.g. if one worker seems to be stuck): * PID: 4273 Sessions: 1 Processed: 47 Uptime: 50m 53s CPU: 43% Memory : 3644M Last used: 49m 24s ago
...request_body_fully_read" : true, "request_body_type" : "NO_BODY", "response_begun" : false, "session" : { "gupid" : "18asd3ed-U4FSeggT0O", "pid" : 4273 }, "last_data_send_time" : null, tells me, that this process did...
...can list them like this: $ git stash list stash@{0}: WIP on feature/foo stash@{1}: WIP on feature/bar stash@{2}: WIP on fix/baz All those stashed changes have their own...
...reference (like branch names) that you can look at, like stash@{0}, stash@{1}, etc. Above, we looked at stash@{0} which is the default for stash actions.
# for which the block evaluates to true, # the second containing the rest. (1..6).partition { |v| n.even? } #=> [[2, 4, 6], [1, 3, 5]] Works well with destructuring assignment...
even, odd = (1..6).partition { |n| n.even? } even #=> [2, 4, 6]
The sprintf method has a reference by name format option: sprintf("% d : % f", { :foo => 1, :bar => 2 }) # => 1 : 2.000000 sprintf("%{foo}f", { :foo => 1 }) # => "1f" The format identifier % stands for...
...different data types to be formatted, such as %f for floats: sprintf('%f', 1) # => 1.000000 Example: This is quite useful to replace long strings such as API endpoints which might...
...database's EXPLAIN style. For example, it looks like this on MySQL: User.where(id: 1).includes(:articles).explain EXPLAIN for: SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 +----+-------------+-------+-------+---------------+
...type | table | type | possible_keys | +----+-------------+-------+-------+---------------+ | 1 | SIMPLE | users | const | PRIMARY | +----+-------------+-------+-------+---------------+ +---------+---------+-------+------+-------+ | key | key_len | ref | rows | Extra | +---------+---------+-------+------+-------+ | PRIMARY | 4 | const | 1 | | +---------+---------+-------+------+-------+ 1 row in set (0.00 sec) EXPLAIN for: SELECT `articles...
2 application servers 6 Rails worker processes in each application server 1 background job server with Sidekiq (will spawn 10 threads by default) When your code does...
...you may use the following number of connections: (2 app servers * 6 app workers) + (1 job server * 10 sidekiq workers) = 12 + 10 = 22 connections When your code does use ActiveRecord...
...has_many :users end Here activity 42 has four users: activity = Activity.find(42) activity.users.ids # => [1, 2, 3, 4] Let's say we want to do the same on all activities...
...By reloading the object, its full list of associated users is restored: activity.reload.users.ids # => [1, 2, 3, 4] Or you can reset the association cache: activity.users.reset # newer Rails activity.users(true) # old...
Unfiltered: `User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."token" = $1 LIMIT $2 [["token", "secret-token"], ["LIMIT", 1]]` After the filter is applied:
...ms) SELECT "users".* FROM "users" WHERE "users"."token" = $1 LIMIT $2 [["token", "[FILTERED]"], ["LIMIT", 1]]` Unfortunately, this mechanism is not always applied, because of code dependencies. Some are written by...
attribute attr end validates *REQUIRED_ATTRIBUTES, presence: true validates *ALL_ATTRIBUTES, length: { maximum: 1000 } # From this you already get methods like `#valid?` and `#==`. # (optional) Here is the perfect place...
...Address instance: # without :mapping Rails uses keyword arguments Address.new(street_and_number: 'Foo St. 1', zip_code: '12345', city: 'Bar Town') # with a :mapping (even if that is just the...
The git doc states on the difference of these two commands: git-restore[1] is about restoring files in the working tree from either the index or another commit. This...
...also be used to restore files in the index from another commit. git-reset[1] is about updating your branch, moving the tip in order to add or remove commits...
...This task list is divided by the Gate keeping process in the following steps: 1. Starting a new feature 2. Working on the issue 3. Finishing a feature
...design and the points from Building web applications: Beyond the happy path The template: 1 Starting a new feature Set the issue to "In Progress" in Linear Pull the most...
...einige übliche nennen. Du kannst den folgenden Response Code Kategorien einen Überbegriff/Kategorienamen zuordnen: 1xx 2xx 3xx 4xx 5xx Was ist ein HTTP Body? Wo ist der Unterschied zu einem...
...Evolution of HTTP HTTP/1.1 vs HTTP/2: What's the Difference? HTTP cookies WebSockets in 100 Seconds & Beyond with Socket.io WebSockets Explained Cross-Origin Resource Sharing (CORS) Content Security Policy (CSP...
...a new frame is rendered 60 times a second. Thus, a single frame is 1000ms / 60 = 16.6...ms long. Once a frame renders longer than 16ms, the page will begin...
...s well searchable when you just have a question about some function. Performance issue 1: Slow JavaScript If an event occurs and JavaScript has to run, the browser have to...
...a running JVM process you can use jcmd. List the running processes: $ jcmd -l 1 /app.jar 140 jdk.jcmd/sun.tools.jcmd.JCmd -l The first column shows the PID of the process.
...system configuration with the PID: $ jcmd 1 VM.system_properties 1: #Thu Jan 26 10:34:20 UTC 2023 java.specification.version=17 sun.jnu.encoding=UTF-8 java.class.path=/app.jar java.vm.vendor=Eclipse Adoptium sun.arch.data.model...
...die Web Security 🇩🇪 provides essentials for the topic of this card. Read following chapters: (1) Security Principles (3.3) Sessions and Cookies (3.5) Same-Origin-Policy (4.2) Angriffsfläche / Attack Surface...
...Kryptographische Grundlagen (7) Authentifikation (8) Authorization (9) Session Management Ohne (9.4) JSON Web Tokens (10) Federation / Single-Sign on (11) Serverseitige Angriffe (12) Clientseitige Angriffe (13) Clientseitige Schutzmaßnahmen
...to the db you can list your keyspaces/databases with: # Show info about all databases 127.0.0.1:6379> INFO keyspace # Keyspace db0:keys=2674,expires=2663,avg_ttl=99821491105
...expires=466,avg_ttl=33842000297 db2:keys=12,expires=6,avg_ttl=23445951871 In this example you can see that we have 3 DBs. If you are unsure which DB...
...using Geordi, disable automatic updating of chromedriver in ~/.config/geordi/global.yml: auto_update_chromedriver: false Option 1: Use Geordi The geordi gem can upgrade to the correct version of chromedriver: geordi chromedriver...
...z "$VERSION" ]; then echo "Failed to read current version from $VERSION_URL. Aborting." exit 1 else echo "Current version is $VERSION" fi # Abort script if any of the next commands...
...within the diff. Colors The value for color configuration variables is a list of 1-2 colors and 0-1 attributes, separated by spaces. Colors: normal, black, red, green, yellow...
...Read the following chapters from The Pragmatic Programmer, anniversary edition (in our library): Chapter 1, Topic 3: Software Entropy Chapter 2, Topic 9: The Evils of Duplication Chapter 2, Topic...
...10: Orthogonality Chapter 5, Topic 28: Decoupling (and the Law of Demeter) Read the following chapters from Clean Code (in our library): Chapter 1: Clean Code Chapter 2: Meaningful Names...
Why nouns from the client domain do not always map to Ruby models 1:1. E.g. although an "address book contact" and a "user" are both human beings, it...
...a SHA1 revision. Your editor will open with a file like pick fda59df commit 1 pick x536897 commit 2 pick c01a668 commit 3 Each line represents a commit (in chronological...
...these commits into a single one, change the file to this: pick fda59df commit 1 squash x536897 commit 2 squash c01a668 commit 3 This means, you take the first commit...
end def db_number # Returns a number between 2 and n. # Redis db#1 is used for development. db_number = 1 if rails_env == 'test' normalized_test_number = [ENV...
...TEST_ENV_NUMBER'].to_i, 1].max db_number += normalized_test_number end db_number end def port case rails_env when 'staging' # when 'production' # else 6379 # default Redis port...