Skip to content

Instantly share code, notes, and snippets.

View ThomazPom's full-sized avatar

ThomazPom ThomazPom

View GitHub Profile
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\directory\background\shell\ps1]
@="Open Powershell"
"Icon"="powershell.exe"
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_CLASSES_ROOT\directory\background\shell\ps1\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"

AHK Script: Remapping Insert Key

Purpose

This script globally disables the default behavior of the Insert key, as I never use it as intended. Instead, it remaps both the standard Insert key and the Numpad Insert key to function as Shift + Insert. This is useful when I mean to press Shift + Insert but mistakenly press only the Insert key.

Behavior

  • Numpad Insert: Remapped to act as Shift + Insert. Holding the Shift key allows multiple presses of the Insert key without releasing Shift.
  • Standard Insert: Also remapped to Shift + Insert for consistency.

Code

SSL Certificate Generation Script

This script generates a self-signed root CA certificate and a server certificate using OpenSSL. It also includes subject alternative names (SANs) for custom DNS entries. The commands are structured to create certificates valid for 100 years (36500 days).

Steps:

  1. Define Subject for Certificates: The suj variable defines the subject for the certificate.

suj="//appcompat=1/C=FR/ST=PACA/L=AP/O=$cname/OU=Securite/CN=Thomas Benhamou/emailAddress=$username@$cname.com"

USB Video Capture with FFmpeg

This guide explains how to capture video and audio from a USB capture device and process it using FFmpeg in two steps. The current method captures video at a custom frame rate with sound, followed by a second step to process the video.

Step 1: Capture Video and Audio

The first command captures both video and audio using a USB video capture device and a virtual audio source. It records the video at 34 frames per second for 200 seconds.

ffmpeg -f dshow -rtbufsize 100M -i video="usb video" -f dshow -i audio="virtual-audio-capturer" -preset ultrafast -framerate 34 -t 200 -y output2.mp4
const { execSync } = require('child_process');
function deleteWorkflowRuns(username, reponame) {
if (!username || !reponame) {
console.log("Usage: deleteWorkflowRuns(username, reponame)");
return 1;
}
console.log(`Fetching workflow runs for ${username}/${reponame}...`);
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
function playNote(frequency, duration,cancontinue) {
// create Oscillator node
var oscillator = audioCtx.createOscillator();
oscillator.type = 'square';
oscillator.frequency.value = frequency; // value in hertz
oscillator.connect(audioCtx.destination);
oscillator.start();
function discoverAllShadowRoots(){
let shadowroots = []
function discover(elem){
let elemshadowroots = [...elem.querySelectorAll("*")]
elemshadowroots.push(elem)
elemshadowroots=elemshadowroots.map(z=>z.shadowRoot).filter(z=>z)
elemshadowroots.forEach(discover)
shadowroots.push(...elemshadowroots)
}
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
int emit(int value=1008,int protocol=6,int wordlen=12)
{
String must_send = intToBinaryWord(value,wordlen);
@ThomazPom
ThomazPom / gimp_smart_remove_bg.py
Last active September 1, 2022 20:07
Execute this in gimp python fu console to remove black backgrounds from png images while keeping accurate colors
import glob, os
def smart_remove_bg(folder,rem_color="#000000"):
for filename in glob.glob(folder.replace('"','').strip()):
out_fname = os.path.join(os.path.dirname(filename),"out-"+os.path.basename(filename))
out_fname_xcf = os.path.join(os.path.dirname(filename),"xcf-"+os.path.basename(filename)+".xcf")
image = pdb.file_png_load(filename, filename)
drawable = pdb.gimp_image_get_active_drawable(image)
pdb.plug_in_colortoalpha(image, drawable, rem_color)
<?php
foreach ([1] as $i) if ($condition) { // Breakable if
//some code
$a = "b";
// Le break
break;
// code below will not be executed
}
for ($i=0; $i < 1 ; $i++) if ($condition) {
//some code