Skip to content

Instantly share code, notes, and snippets.

@weshouman
weshouman / README.md
Last active August 20, 2023 20:04
Kernel module dependency walker

Those scripts are used to walk the dependencies of the Kernel Modules in Linux.

Usage

One could use any of the following implementation, either on Python or Bash

Note: The python implementation is updated to use a cache, making it instantaneous

Python Script

Use any of the following commands

simple:
source get_device.sh
getdevicename 1234:abcd
getdevicenum 1234:abcd
script:
#Device VENDOR ID
: ${DEVICE_VENDOR:="1234"}
#Device PRODUCT ID
: ${DEVICE_PRODUCT:="abcd"}
@weshouman
weshouman / pycom.py
Last active July 28, 2022 05:08 — forked from vlasenkov/pycom.py
win32com multithreading example
# win32com multithreading example
import sys
import time
from threading import Thread
# sys.coinit_flags has to be set before importing pythoncom and win32com, otherwise the following errors would be showing up
# - The application called an interface that was marshalled for a different thread.
# - This COM object can not automate the makepy process - please run makepy manually for this object
sys.coinit_flags = 0  # pythoncom.COINIT_MULTITHREADED == 0
@weshouman
weshouman / README.md
Last active June 9, 2022 08:49
npm common issues

NPM package installation behind a proxy

While installing yo behind proxy you may get issues as described in this issue The root cause is that yo is trying to connect to the internet while doing the sanity checks on your system using a global proxy as described here and there

I was not able to change the GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE from undefined to an empty variable from the powershell, so I edited the node_modules\got\index.js:requestAsEventEmitter(opts):~22 and added the following line

	process.env.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE="";
@weshouman
weshouman / VS16NoTelem.bat
Created April 28, 2022 16:55
Disable telemetry in Visual Studio 2019
@echo off
fltmc >nul 2>&1 || (
echo This batch script requires administrator privileges. Right-click on
echo the script and select "Run as administrator".
goto :die
)
rem Change this path if you are using Community or Professional editions
set "VS_INSTALL_DIR=%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise"
wget -O /tmp/YaHei.Consolas.1.12.zip https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/uigroupcode/YaHei.Consolas.1.12.zip
unzip /tmp/YaHei.Consolas.1.12.zip
sudo mkdir -p /usr/share/fonts/consolas
sudo mv YaHei.Consolas.1.12.ttf /usr/share/fonts/consolas/
sudo chmod 644 /usr/share/fonts/consolas/YaHei.Consolas.1.12.ttf
cd /usr/share/fonts/consolas
sudo mkfontscale && sudo mkfontdir && sudo fc-cache -fv
@weshouman
weshouman / README.md
Created September 11, 2021 04:10
parsers tips and tricks
@weshouman
weshouman / 0_urllib2.py
Created June 9, 2021 07:40 — forked from kennethreitz/0_urllib2.py
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
@weshouman
weshouman / Makefile
Last active March 3, 2024 10:39
arduino cli tips
VERSION=0.14.0
SPECIFIER=arduino-cli_${VERSION}_Linux_64bit
BINDIR=/usr/local/bin/
# - Avoid redownloading
# - Avoid overwriting
# - To overwrite, use make uninstall
install:
TMPDIR=/tmp/$(SPECIFIER) && \
mkdir -p $${TMPDIR} && \
@weshouman
weshouman / gimp_img_downsize.py
Created November 29, 2020 19:17 — forked from amatelin/gimp_img_downsize.py
A simple script to automatically downsize all the images in a folder using Gimp python console (Gimp->Filters/Python-Fu/console).
from os import listdir
from os.path import isfile, join
## Set image folder path
dir_path = "C:/img_dir/"
## Store files names in folder
files = [f for f in listdir(dir_path) if isfile(join(dir_path, f))]
for file in files: