Skip to content

Instantly share code, notes, and snippets.

View umaar's full-sized avatar

Umar Hansa umaar

View GitHub Profile
@umaar
umaar / batch-worker-host.ts
Created December 8, 2024 02:40 — forked from eranbetzalel/batch-worker-host.ts
This class provides an efficient and flexible way to handle batch processing of jobs in a BullMQ environment, leveraging NestJS. It ensures that jobs are processed in batches, which can be crucial for performance optimization in applications requiring bulk operations..
import {WorkerHost} from '@nestjs/bullmq';
import {Job} from 'bullmq';
export class BatchWorkerHost extends WorkerHost {
private jobBatchCreationTime: Date;
private jobBatch: Job[];
private jobBatchProcessPromise: Promise<void>;
private running: boolean = false;
private resolveJobBatchProcessPromise: () => void;
@umaar
umaar / rails-production-setup.sh
Created October 2, 2024 21:11 — forked from rameerez/rails-production-setup.sh
Rails Production Server Setup - Set up a new Ubuntu Server 24.04 LTS to run a Rails 7 app, using Capistrano for deployment
#!/bin/bash
# This script takes a clean Ubuntu Server 24.04 LTS AMI and installs and configures
# everything needed to deploy a Rails 7 app to it. The resulting state is a secure,
# production-ready instance.
set -euo pipefail
# --- AESTHETICS ---
@umaar
umaar / pygmentize_code.sh
Created February 5, 2023 00:54 — forked from skmetz/pygmentize_code.sh
Script to create syntax highlighted RTF files
#!/bin/bash
# I edited the ruby lexer (line 637 in the following file...
# [skm@skmair2:/Library/Python/2.7/site-packages/pygments/lexers/agile.py
# to remove spacial handling of the word 'name'
# so I could use it as a variable/method name.
# This script come from Katrina, with these instructions:
# I've also attached the presentation.py file which is where the style
# is defined. The colors are normal hex values, so if you know how you
@umaar
umaar / 1-CalendarItem.js
Created August 4, 2022 00:08 — forked from getify/1-CalendarItem.js
an illustration (non-trivial example) of many newer JS class features
// abstract class, not intended to be instantiated directly
class CalendarItem {
static #UNSET = Symbol("unset")
static #isUnset(v) {
return v === this.#UNSET;
}
static {
for (let [idx,msg] of [
"ID is already set.",
"ID is unset.",
@umaar
umaar / scale.js
Created March 31, 2021 23:11 — forked from fpillet/scale.js
Javascript value scaling between two ranges
/* Scale a value from one range to another
* Example of use:
*
* // Convert 33 from a 0-100 range to a 0-65535 range
* var n = scaleValue(33, [0,100], [0,65535]);
*
* // Ranges don't have to be positive
* var n = scaleValue(0, [-50,+50], [0,65535]);
*
* Ranges are defined as arrays of two values, inclusive
// main.js
import {cat} from './animals.js'
cat();
// animals.js
function cat() {
console.log('meow');
}

A crawler is a search engine tool which finds webpages to navigate through. Search engines can discover pages more easily when the href attribute of an anchor element is present, and contains a crawlable hyperlink.

How the Lighthouse link text audit fails

Lighthouse flags anchor elements with uncrawlable hyperlinks:

<insert screenshot here>

Lighthouse flags the following anchor elements as being uncrawlable:

<a class="duf3 aciXEb" href="#" id="sbfblt" data-async-trigger="duf3-46" jsaction="async.u" data-ved="0ahUKEwisrODf1t7oAhWHy6QKHYmbAEsQtw8IDA">Report inappropriate predictions</a>
<a href="#" data-async-trigger="ddlshare" title="Share" jsaction="async.u" data-ved="0ahUKEwisrODf1t7oAhWHy6QKHYmbAEsQ4zgIEA"><div class="dnNgC" style="background-color:#ffffff;border:2px solid #ffffff;opacity:0.800000011920929"></div><input value="//g.co/doodle/w4sr6" class="ddl-shortlink" type="hidden"><input value="//g.co/doodle/1duj2" class="ddl-facebooklink" type="hidden"><input value="//g.co/doodle/gqtwe" class="ddl-twitterlink" type="hidden"><input value="//g.co/doodle/s4vq2" class="ddl-emaillink" type="hidden"><input value="" class="ddl-copylink" type="hidden"><img class="fJOQGe" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAoUlEQVR42mMwnmnMQAZ2AGIQfADFM6FicDXkGnoGiP+j4TPIhpNj8EwshsLwTEoMfoDH4AeDzmBnIL5MalDgi2kZIF6JZMAtYiMPV0yfhVrwGcoH0RVA7EJ