Skip to content

Instantly share code, notes, and snippets.

import PDFParser from 'pdf2json';
import { test, expect } from '@playwright/test';
test.describe('assert PDF contents using Playwright', () => {
let pdfContents: any
test.beforeAll(async () => {
pdfContents = await getPDFContents('./pdf_sample.pdf')
})
test('pdf file should have 6 pages', async () => {
@iqbmo04
iqbmo04 / WinRM-HTTPS.ps1
Created February 17, 2023 15:47 — forked from TechIsCool/WinRM-HTTPS.ps1
A simple Powershell WinRM-HTTPs setup
Write-Output "Disabling WinRM over HTTP..."
Disable-NetFirewallRule -Name "WINRM-HTTP-In-TCP"
Disable-NetFirewallRule -Name "WINRM-HTTP-In-TCP-PUBLIC"
Get-ChildItem WSMan:\Localhost\listener | Remove-Item -Recurse
Write-Output "Configuring WinRM for HTTPS..."
Set-Item -Path WSMan:\LocalHost\MaxTimeoutms -Value '1800000'
Set-Item -Path WSMan:\LocalHost\Shell\MaxMemoryPerShellMB -Value '1024'
Set-Item -Path WSMan:\LocalHost\Service\AllowUnencrypted -Value 'false'
Set-Item -Path WSMan:\LocalHost\Service\Auth\Basic -Value 'true'
@iqbmo04
iqbmo04 / cleanup-gitlab-pipelines.sh
Created December 8, 2022 15:54 — forked from chrishoerl/cleanup-gitlab-pipelines.sh
Bulk delete gitlab pipelines older than a given date
#!/bin/bash
# Purpose: Bulk-delete GitLab pipelines older than a given date
# Author: github.com/chrishoerl
# GitLab API: v4
# Requirements: jq must be instaled ($ sudo apt install jq)
# API example: https://gitlab.example.com/api/v4/projects
# API example: https://gitlab.example.com/api/v4/projects/<projectid>/pipelines
#
# NOTE: Script is just a dryrun. To really delete pipelines, simply uncomment line 49 to activate
#
@iqbmo04
iqbmo04 / axios-interceptors-refresh-token.js
Created October 26, 2022 09:32 — forked from mkjiau/axios-interceptors-refresh-token.js
Axios interceptors for token refreshing and more than 2 async requests available
let isRefreshing = false;
let refreshSubscribers = [];
const instance = axios.create({
baseURL: Config.API_URL,
});
instance.interceptors.response.use(response => {
return response;
}, error => {
@iqbmo04
iqbmo04 / date.extensions.ts
Created October 18, 2022 15:05 — forked from weslleih/date.extensions.ts
Extend the TypeScript Date Object with some useful methods
export {}
declare global {
interface Date {
addDays(days: number, useThis?: boolean): Date;
isToday(): boolean;
clone(): Date;
isAnotherMonth(date: Date): boolean;
isWeekend(): boolean;
isSameDate(date: Date): boolean;
@iqbmo04
iqbmo04 / command.system.js
Created September 22, 2022 09:48 — forked from nijikokun/command.system.js
Javascript Function Annotations, can be used for anything. Enjoy.
/*
* Javascript Annotations
*
* Maybe I am ahead of my time, or behind the times (asm.js).
* Either way, this is how they work (or could work) if you aren't afraid of some simple RegExp magic.
*
* @author Nijiko Yonskai
* @license MIT (or whatever college/license/name you prefer ;)
* @copyright 2013
*/
@iqbmo04
iqbmo04 / retryRequest.js
Created August 8, 2022 12:11
cypress request with retries
Cypress.Commands.add('retryRequest', (url, options) => {
Cypress._.defaults(options, {
method: 'GET',
body: null,
headers: {
'content-type': 'application/json'
},
retries: 0,
function: false,
timeout: 0
@iqbmo04
iqbmo04 / bundle.js
Created August 4, 2022 19:13 — forked from jackgill/bundle.js
A node.js script to create a bundle containing an npm package, and all of its dependencies.
/*
* This script will download a package (and all of its dependencies) from the
* online NPM registry, then create a gzip'd tarball containing that package
* and all of its dependencies. This archive can then be copied to a machine
* without internet access and installed using npm.
*
* The idea is pretty simple:
* - npm install [package]
* - rewrite [package]/package.json to copy dependencies to bundleDependencies
* - npm pack [package]
@iqbmo04
iqbmo04 / cheatsheet.ps1
Created July 28, 2022 08:43 — forked from pcgeek86/cheatsheet.ps1
PowerShell Cheat Sheet / Quick Reference
Get-Command # Retrieves a list of all the commands available to PowerShell
# (native binaries in $env:PATH + cmdlets / functions from PowerShell modules)
Get-Command -Module Microsoft* # Retrieves a list of all the PowerShell commands exported from modules named Microsoft*
Get-Command -Name *item # Retrieves a list of all commands (native binaries + PowerShell commands) ending in "item"
Get-Help # Get all help topics
Get-Help -Name about_Variables # Get help for a specific about_* topic (aka. man page)
Get-Help -Name Get-Command # Get help for a specific PowerShell function
Get-Help -Name Get-Command -Parameter Module # Get help for a specific parameter on a specific command
@iqbmo04
iqbmo04 / download-pdf.js
Created July 27, 2022 14:27 — forked from devloco/download-pdf.js
Download a PDF via POST with Fetch API
let fnGetFileNameFromContentDispostionHeader = function (header) {
let contentDispostion = header.split(';');
const fileNameToken = `filename*=UTF-8''`;
let fileName = 'downloaded.pdf';
for (let thisValue of contentDispostion) {
if (thisValue.trim().indexOf(fileNameToken) === 0) {
fileName = decodeURIComponent(thisValue.trim().replace(fileNameToken, ''));
break;
}