Skip to content

Instantly share code, notes, and snippets.

@telecran-telecrit
telecran-telecrit / PyMuPDF_fitz_ample.py
Created August 6, 2024 04:35
To extract text from PDF you can try my code examples
import re
import fitz
def validate_resume(filename):
# Open the PDF file and read its contents
with fitz.open(filename) as pdf:
resume_text = ''
for page in pdf:
resume_text += page.get_text()
# Check for certain keywords or phrases in the resume text
@telecran-telecrit
telecran-telecrit / spoiler
Created July 22, 2024 20:37 — forked from beardlessman/spoiler
Spoiler [like jquery-ui accordion(no)]
//js
$('.j-spoiler').each(function(){
new Spoiler(this);
});
Spoiler = function(container) {
this.container = $(container);
this.head = this.container.find('.j-spoiler-head');
this.body = this.container.find('.j-spoiler-body');
this.close = this.container.find('.j-spoiler-close');
this.init();
@telecran-telecrit
telecran-telecrit / read_write_lock.py
Created May 2, 2024 12:47 — forked from Eboubaker/read_write_lock.py
Python Reentrant Read Write Lock: Allowing Multithreaded Read Access While Maintaining a Write Lock
import threading
from typing import List
class ReentrantRWLock:
"""
A lock object that allows many simultaneous "read locks", but only one "write lock."
it also ignores multiple write locks from the same thread
"""
@telecran-telecrit
telecran-telecrit / rwlock.py
Created May 2, 2024 12:46 — forked from tylerneylon/rwlock.py
A simple read-write lock implementation in Python.
# -*- coding: utf-8 -*-
""" rwlock.py
A class to implement read-write locks on top of the standard threading
library.
This is implemented with two mutexes (threading.Lock instances) as per this
wikipedia pseudocode:
https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock#Using_two_mutexes
@telecran-telecrit
telecran-telecrit / save-rendered-html-to-clipboard1.js
Last active February 25, 2024 21:40
Save rendered html page to clipboard
// Instead of unrendered content (Ctrl+U, Ctrl+A, Ctrl+C)
// See also https://gist.github.com/telecran-telecrit/4a392087d5cc241404c83bb32009a25f (imageToUri)
///////////////////////////////////////////////////////////////////
function isScriptExternal (scriptElement, oldSrc) {
if (!oldSrc) {
oldSrc = scriptElement.src;
}
return (!!oldSrc && (oldSrc[0] != '#' || oldSrc.startsWith('#external/')));
}
@telecran-telecrit
telecran-telecrit / example1.js
Last active February 25, 2024 15:00
JS image to data uri
function imageToUri (url, callback) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
var base_image = new Image();
base_image.crossOrigin="anonymous";
base_image.src = url;
base_image.onload = function() {
canvas.width = base_image.width;
canvas.height = base_image.height;
ctx.drawImage(base_image, 0, 0);
@telecran-telecrit
telecran-telecrit / bash.cmd
Created October 1, 2023 08:34
Math for Python 2.7 # 3.8
pip2 install numpy==1.15.0 pypng==0.0.20 pyparsing==1.5.6 cycler==0.10.0 lxml==3.2.3 matplotlib==1.5.1 pandas==0.23.1 SciPy==1.8.1 Seaborn # pip3 install numpy pypng pyparsing cycler lxml matplotlib matplotlib==3.2.2 pandas SciPy==1.8.1 Seaborn