Skip to content

Instantly share code, notes, and snippets.

@secemp9
secemp9 / pass-sync.sh
Created April 26, 2021 19:58
pass-sync across two directories.
pass() { if [[ "$1" == "generate" || "$1" == "edit" || "$1" == "rm" || "$1" == "mv" || "$1" == "cp" || "$1" == "git" || "$1" == "insert" ]]; then command pass "$@" ; echo -n "Backup Started..." && cd ~/.password-store ; git pull pass_disk master -v ; cd /mnt/sda1/.password-store ; git pull pass_home master -v ; echo "Done!"; else command pass "$@"; fi; }
@secemp9
secemp9 / html2text_weird.py
Last active June 2, 2021 09:16
html2text but it's a weird version
"""html2text: Turn HTML into equivalent Markdown-structured text."""
import html.entities
import html.parser
import re
import string
import urllib.parse as urlparse
from textwrap import wrap
from typing import Dict, List, Optional, Tuple, Union
import argparse
@secemp9
secemp9 / viewless.py
Last active July 2, 2021 09:49
Text editor used as Text viewer (Prototype 0)
import sys
import curses
import io
import locale
import os
import binascii
class Editor:
def __init__(self, win, file_name):
self.win = win
@secemp9
secemp9 / pip-bundle.py
Created November 29, 2021 09:19
pip-bundle custom
# -*- coding: utf-8 -*-
#
# Copyright 2015 Develer S.r.l. (http://www.develer.com/)
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
@secemp9
secemp9 / __init__.py
Last active December 3, 2021 17:27
bpython oldest version but it's a compound of bugs (cli.py is the main file)
# The MIT License
#
# Copyright (c) 2008 Bob Farrell
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@secemp9
secemp9 / pygametk.md
Last active August 22, 2022 17:00
pygame + tkinter on separate threads...because why not

So this is just me experimenting...

Anyway, there a peculiar error without the if block at 69 LOC. If you keep everything but just remove the if condition + the time.sleep, then proceed to decrement/increment the variable "width" using the tkinter buttons "Up" and "Down" fast enough (I used two fingers because there no key repetitoon support on the tkinter function I made), you get this:

Process finished with exit code -1073740791 (0xC0000409)

After a while, I found that the likely cause is one of the variable/memory part of pygame/tkinter that try to access something that isn't likely there, or not "ready" yet? (eg: not initialized, etc). But on retrospect, I probably don't know the exact cause. Here an example I found on stackoverflow: https://stackoverflow.com/questions/50562192/process-finished-with-exit-code-1073740791-0xc0000409-pycharm-error

@secemp9
secemp9 / linux_pipe_python.md
Created August 22, 2022 16:07
Emulating linux pipes on python 101 (or is it??)

I'm gonna make this quick because time is piping itself away! (bad joke)

So how to make a linux pipe with/under/inside/you_get_it python?

First, let's take into account the context here: is it just as syntax? or as an actual linux pipes? buffering only?

Your context for what you want in your linux pipe emulation need to be defined, but before you do it, let me list a couple of possibility:

If it's just syntax then:

  • AST
import tkinter as tk
import platform
# ************************
# Scrollable Frame Class
# ************************
class ScrollFrame(tk.Frame):
def __init__(self, parent):
super().__init__(parent) # create a frame (self)
@secemp9
secemp9 / test.py
Created September 21, 2022 17:22
subprocess without spawning terminal on windows 10
import subprocess
info = subprocess.STARTUPINFO()
info.dwFlags = subprocess.STARTF_USESTDHANDLES | subprocess.STARTF_USESHOWWINDOW
info.wShowWindow = subprocess.SW_HIDE
@secemp9
secemp9 / hotspot2.py
Created September 21, 2022 17:52
restart wifi hotspot on windows 10
import subprocess
import time
info = subprocess.STARTUPINFO()
info.dwFlags = subprocess.STARTF_USESTDHANDLES | subprocess.STARTF_USESHOWWINDOW
info.wShowWindow = subprocess.SW_HIDE
def run(cmd):
completed = subprocess.run(["powershell", "-Command", cmd], capture_output=True, startupinfo=info)