Skip to content

Instantly share code, notes, and snippets.

View osmianski's full-sized avatar

Vlad Osmianski osmianski

View GitHub Profile
@osmianski
osmianski / routes.php
Last active April 13, 2023 11:00
Benchmarking resolving an instance from the Laravel container against raw `new` operator. Run this here: <https://laravelplayground.com/#/>
<?php
class Test
{
}
Route::get('/', function (){
$output = '';
$count = 10000;
@osmianski
osmianski / nfc.html
Created September 12, 2022 05:04
Put this file under HTTPS server, access it from your phone's Chrome, and scan NFC tags around you :)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NFC Test</title>
</head>
<body>
<button id="scan" style="display: none;">Scan</button>
@osmianski
osmianski / gist:225bc158c910be534d7ddcfc582685c6
Last active March 14, 2022 06:37
Useful queries for checking ElasticSearch indexes
# list all indexes
curl 'localhost:9200/_cat/indices?v'
# dump the index definition into a file
curl 'localhost:9200/{index}/_mapping?pretty' > ~/es_schema.json
# dump the index into a file
curl -XPOST 'localhost:9200/{index}/_search?pretty' \
-H "Content-Type: application/json" \
-d '{"size": 10000, "query": { "match_all": {} }}' > ~/es_data.json
@osmianski
osmianski / gist:a2cacdabf3b62d848a65049ba31cb5a3
Created January 27, 2022 09:04
Measuring performance using PHP microtime()
$startedAt = microtime(true);
...
// in milliseconds
$elapsed = (microtime(true) - $startedAt) * 1000;