This is an interactive metric. Collected once user tries to interact with the page.
Using web-vitals npm package
import {getFID} from 'web-vitals';
getFID(console.log);
<?php | |
// from http://php.net/manual/en/function.filesize.php | |
function formatBytes($bytes, $precision = 2) { | |
$units = array('B', 'KB', 'MB', 'GB', 'TB'); | |
$bytes = max($bytes, 0); | |
$pow = floor(($bytes ? log($bytes) : 0) / log(1024)); | |
$pow = min($pow, count($units) - 1); | |
This is an interactive metric. Collected once user tries to interact with the page.
import {getFID} from 'web-vitals';
getFID(console.log);
Quick file serving with lightweight & efficient webserver using nginx:1.25-alpine
Quick project aims to demonstrate the creation, deployment of a lightweight & efficient web server using Nginx running on an Apline Linux based Docker container. The project serve static files from any mounted folder, making an ideal solution for hosting simple website, front-end applications, or any content that needs to be served from a folder / local system.
CNAME=nginx-8080
function getRandomCharacter(charset = "" ){ | |
const randomIndex = Math.floor(Math.random() * charset.length); | |
return charset.charAt(randomIndex); | |
} | |
function generatePassword(length) { | |
const charsetAlphabets = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$?"; | |
// const charsetNumbers = "0123456789"; | |
// const specialCharacters = "!@#$?" | |
I wonder if i can see all the lcp elements instead of getting the eventual lcp element from the performance panel. Below script higlights all lcp elements available on the page. After running the script in console / source - snippet it highlight by a dotten blue line for all lcp elements. This uses browser's PerformanceObserver API to get all lcp elements.
By @samarpanda
/**
* PerformanceObserver
*/
#For jpeg files | |
#Need to install jpegtran in ubuntu | |
sudo apt-get install libjpeg-progs | |
Usage tips: | |
#To optimise a single jpeg image: | |
jpegtran -copy none -optimise -outfile image.jpg image.jpg | |
#To optimise all jpegs in the current directory: | |
for img in `ls *.jpg`; do jpegtran -copy none -optimise -outfile $img $img; done |
Alt
or Command
and then click in each region where you require a cursor.Shit
+ Command
+ LCommand + F
then Option + Enter
. All the occurance of the word should be editable.The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.