Skip to content

Instantly share code, notes, and snippets.

@SivaramPg
SivaramPg / pdf2base64.js
Last active March 29, 2024 12:34
Convert a PDF file to Base64 String
const pdfFilePath = path.resolve(__dirname, './sample.pdf');
/**
* https://www.npmjs.com/package/pdf2pic
* https://github.com/yakovmeister/pdf2image#readme
*
* Following is an overview of the options that can be passed on the pdf2pic methods:
* quality - set output's image quality
* format - set output's file format
* width - set output's width
@SivaramPg
SivaramPg / buffer2png.js
Last active March 29, 2024 12:34
Convert Base64 image URI to buffer and read buffer as PNG
/**
* https://www.npmjs.com/package/pngjs
* https://github.com/lukeapage/pngjs
* Recreate PNG with metadata from extracted Base64 data URI
*/
const buffer = Buffer.from(dataUri, 'base64');
const png = PNG.sync.read(buffer);
@SivaramPg
SivaramPg / png-qr-code-extractor.js
Last active March 29, 2024 12:34
Read and display QR Code from PNG created using pngjs.
/**
* https://www.npmjs.com/package/jsqr
* https://github.com/cozmo/jsQR#readme
* Extract the Code from recreated PNG using jsQR
*/
const code = jsQR(Uint8ClampedArray.from(png.data), png.width, png.height);
const qrCodeText = code?.data;
console.log('QR Code Text: ', qrCodeText);
@DHosseiny
DHosseiny / migrate-to-version-catalog.kts
Last active March 29, 2024 12:32
Script to migrate gradle dependencies and plugins to version catalog. This script looks for libs.version.toml file and uses existing added libraries and logs not added libraries(just copy from logs and paste in libraries section)
import java.io.File
val path = "path/to/project/directory" // TODO: change here
println("Processing in folder: $path")
println()
fun writeDependenciesFromVersionCatalog(path: String) {
@PurpleVibe32
PurpleVibe32 / vmwk17key.txt
Last active March 29, 2024 12:31
Free VMware Workstation Pro 17 full license keys
Install VMWare Workstation PRO 17 (Read it right. PRO!)
Also, these keys might also work with VMWare Fusion 13 PRO. Just tested it.
Sub to me on youtube pls - PurpleVibe32
if you want more keys - call my bot on telegram. @purector_bot (THE BOT WONT REPLY ANYMORE) - Or: https://cdn.discordapp.com/attachments/1040615179894935645/1074016373228978277/keys.zip - the password in the zip is 102me.
---
This gist can get off at any time.
PLEASE, DONT COPY THIS. IF YOU FORK IT, DONT EDIT IT.
*If you have a problem comment and people will try to help you!
*No virus
@Kludex
Kludex / main.py
Last active March 29, 2024 12:31
Run Gunicorn with Uvicorn workers in code
""" Snippet that demonstrates how to use Gunicorn with Uvicorn workers in code.
Feel free to run:
- `python main.py` - to use uvicorn.
- `ENV=prod python main.py` - to use gunicorn with uvicorn workers.
Reference: https://docs.gunicorn.org/en/stable/custom.html
"""
@johnfmorton
johnfmorton / proxy-for-partytown.php
Last active March 29, 2024 12:31
Simple proxy with php for use with Partytown
<?php
/**
* About this script:
* This proxy was built with PartyTown.js in mind. https://github.com/BuilderIO/partytown
* Partytown is a lazy-loaded library to help relocate resource intensive scripts into a
* web worker, and off of the main thread.
* Many third-party scripts already provide the correct CORS headers, but not all do.
* For services that do not add the correct headers, then a reverse proxy to another domain must be used in order to provide the CORS headers.
* see: https://github.com/BuilderIO/partytown/wiki/Proxying-Requests
@Crocoblock
Crocoblock / rel-get-items-by-relation.php
Created March 27, 2023 18:55
JetEngine Related Items by Sibling Relation Macro
<?php
add_action( 'jet-engine/register-macros', function(){
class Related_Items_By_Sibling_Relation extends \Jet_Engine_Base_Macros {
public function macros_tag() {
return 'rel_get_items_by_relation';
}