Skip to content

Instantly share code, notes, and snippets.

View mubaidr's full-sized avatar
:shipit:
Adding bugs to web applications!

Muhammad Ubaid Raza mubaidr

:shipit:
Adding bugs to web applications!
View GitHub Profile
Free Windows Server 2022 Standard Product Key
HP9DJ-NK2X6-4QPCH-8HY8H-6X2XY
RRNMT-FP29D-CHKCH-GWQP2-DDDVB
44QN4-X3R72-9X3VK-3DWD6-HFWDM
Free Windows Server 2022 Datacenter Product Key
WX4NM-KYWYW-QJJR4-XV3QB-6VM33
Download windows Sever 2022 Evaluation edition:
Windows Server 2022 Evaluation English
@mubaidr
mubaidr / sse.ts
Created January 12, 2024 09:58 — forked from Atinux/sse.ts
SSE endpoint example with Nuxt 3
// ~/server/api/sse.ts
export default defineEventHandler(async (event) => {
if (!process.dev) return { disabled: true }
// Enable SSE endpoint
setHeader(event, 'cache-control', 'no-cache')
setHeader(event, 'connection', 'keep-alive')
setHeader(event, 'content-type', 'text/event-stream')
setResponseStatus(event, 200)
@mubaidr
mubaidr / fix_vscode_copilot_cert.sh
Last active March 24, 2023 05:14 — forked from davidlu1001/fix_vscode_copilot_cert.sh
Fix Github Copilot cert issue behind proxy for VSCode
#!/usr/bin/env bash
set -uo pipefail
_VSCODEDIR="$HOME/.vscode-insiders/extensions"
_COPILOTDIR=$(ls "${_VSCODEDIR}" | grep -E "github.copilot-[1-9].*" | sort -V | tail -n1) # For copilot
_COPILOTDEVDIR=$(ls "${_VSCODEDIR}" | grep "github.copilot-nightly-" | sort -V | tail -n1) # For copilot-nightly
_COPILOTLABSDIR=$(ls "${_VSCODEDIR}" | grep "github.copilot-labs-" | sort -V | tail -n1) # For gitHub.copilot-labs
_EXTENSIONFILEPATH="${_VSCODEDIR}/${_COPILOTDIR}/dist/extension.js"
@mubaidr
mubaidr / filters.js
Created June 24, 2022 10:01 — forked from deckchairlabs/filters.js
Prisma Custom Generator
#!/usr/bin/env node
const path = require('path')
const generatorHelper = require('@prisma/generator-helper')
const { Project, StructureKind, VariableDeclarationKind } = require('ts-morph')
generatorHelper.generatorHandler({
onManifest(config) {
return {
prettyName: 'Filters',
defaultOutput: path.resolve(__dirname, 'filters'),
@mubaidr
mubaidr / find-missing-index.js
Created May 10, 2021 17:36
How to find missing indexes on foreign keys
// https://medium.com/@awesboss/how-to-find-missing-indexes-on-foreign-keys-2faffd7e6958
describe('database', () => {
describe('performance', () => {
it('has indexes on all foreign keys', async () => {
const query = `
WITH indexed_tables AS (
select
ns.nspname,
t.relname as table_name,
CREATE FUNCTION get_Exact_Date_diff(@date SMALLDATETIME,@date2 SMALLDATETIME)
returns VARCHAR(50)
AS
BEGIN
DECLARE @date3 SMALLDATETIME
DECLARE @month INT,@year INT,@day INT
@mubaidr
mubaidr / rdp.ts
Created December 28, 2020 17:05
Ramer–Douglas–Peucker algorithm in typescript
import { Polygon } from './types/ShapeType'
import { perpendicularDistance } from './utilities'
// distance between two points
function distance(p1: Point, p2: Point): number {
return Math.sqrt((p2.x - p1.x) ** 2 + (p2.y - p1.y) ** 2)
}
// perpendicular distance of a point from a line
@mubaidr
mubaidr / trim_canvas.js
Created October 3, 2020 16:28 — forked from timdown/trim_canvas.js
Returns a copy of a canvas element with surrounding transparent space removed
var trimCanvas = (function() {
function rowBlank(imageData, width, y) {
for (var x = 0; x < width; ++x) {
if (imageData.data[y * width * 4 + x * 4 + 3] !== 0) return false;
}
return true;
}
function columnBlank(imageData, width, x, top, bottom) {
for (var y = top; y < bottom; ++y) {
// This file was initially generated by Windows Terminal Preview 1.1.1671.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
function getSvgAsImage(svgElem, viewBox) {
// TODO: add x,y to w,h
var canvas = document.createElement('canvas')
canvas.width = viewBox[2]
canvas.height = viewBox[3]
var ctx = canvas.getContext('2d')
ctx.fillStyle = '#fff'
ctx.fillRect(0, 0, canvas.width, canvas.height)
var options = {