Skip to content

Instantly share code, notes, and snippets.

@ygilad
ygilad / new_temp_chrome.py
Created February 16, 2024 07:21
Creates a new chrome profile and removes it after usage
import tempfile
import os
import time
import configparser
import sys
import wx
def get_chrome_path_from_user():
app = wx.App(None)
@ygilad
ygilad / web-server-here.sh
Last active January 23, 2024 12:58
Create Web Server on current directory. (uses python, Tested on Mac)
#!/bin/zsh
if [ "$1" != "" ]
then
MYPORT="$1"
else
MYPORT="8080"
fi
MYURL="http://localhost:$MYPORT/"
echo "Opening [$MYURL] (iTerm2 - Press ⌘⌥ to make link clickable)"
@ygilad
ygilad / example.md
Last active February 22, 2024 16:41
Generate image from mermaid code in markdown file

Squence

sequenceDiagram
autonumber

participant UI as UI
participant BS as Business Service
@ygilad
ygilad / resample_generator_to_len.py
Created April 8, 2021 16:40
Scratch or reduce list generator while keeping proportion.
def stretch_to(items, target_len: int, items_len: int = None):
"""
Stretch an array to a longer one where items are uniformly distributed
"""
import random
items_len = len(items) if items_len is None else items_len
for i in items:
for i2 in range(round(random.uniform(0.0, (target_len - 1) / (items_len - 1)))):
yield i
@ygilad
ygilad / README.md
Created November 22, 2020 10:29 — forked from jpflouret/README.md
paste.exe

Pipe contents of windows clipboard to another command

Usage

To pipe the contents of the clipboard to another command (e.g. grep):

paste | grep pattern

To save the contents of the clipboard to a file:

@ygilad
ygilad / Python PDF Password
Created November 11, 2020 12:44 — forked from mrpollo/Python PDF Password
Python PDF Password cracker
#!/usr/local/bin/python
from pyPdf import PdfFileWriter, PdfFileReader
import random
from pprint import pprint as pp
import sys
# sys.setrecursionlimit(10000000)
seed = 'BN9F'
pile = [1]
def getNumber():
@ygilad
ygilad / okta_login_IDaaS_flask.py
Created June 25, 2020 10:38
Python Flask Hosted IAM (Login) with Okta IDaas
# From: https://github.com/okta/samples-python-flask/blob/master/okta-hosted-login/main.py
from flask import Flask, render_template, url_for, redirect
from flask_oidc import OpenIDConnect
app = Flask(__name__)
app.config.update({
'SECRET_KEY': 'SomethingNotEntirelySecret',
'OIDC_CLIENT_SECRETS': './client_secrets.json',
'OIDC_ID_TOKEN_COOKIE_SECURE': False,
@ygilad
ygilad / Trollify.user.js
Last active October 22, 2019 14:39
This userscript will replace all images with a picture of a troll
// ==UserScript==
// @name Trollify
// @namespace Trollifyjs
// @include *
// @author ygilad
// @description This userscript will replace all images with a picture of a troll
// ==/UserScript==
window.addEventListener('load', function() {
var images = document.getElementsByTagName('img');
@ygilad
ygilad / add.python.gitignore
Last active October 7, 2019 09:34
Maintaining my-own ,gitignore file for new projects
curl https://gist.githubusercontent.com/ygilad/44a4873b0d4fa7c056fa7ac271ed6090/raw/python.gitignore > .gitignore
@ygilad
ygilad / img2base64.py
Created July 22, 2019 12:51
Script demonstrating embeding .png file in html
# Copied from https://stackoverflow.com/a/56539453/1853298
# Full credit to https://stackoverflow.com/users/1940851/kent-kostelac
import base64
base64Img = ''
with open("sanity-testing.png", "rb") as imageFile:
base64Img = base64.b64encode(imageFile.read())