Skip to content

Instantly share code, notes, and snippets.

View gsusI's full-sized avatar
💭
🛫

Jesus Iniesta gsusI

💭
🛫
View GitHub Profile
function expandAllThreads() {
console.log("Expanding threads...");
const expandButtons = document.querySelectorAll('button[aria-label^="Expand thread"]');
console.log(`Found ${expandButtons.length} expand buttons`);
expandButtons.forEach(button => button.click());
const moreRepliesButtons = document.querySelectorAll('button.text-tone-2.text-12:not([aria-expanded="true"])');
console.log(`Found ${moreRepliesButtons.length} 'more replies' buttons`);
moreRepliesButtons.forEach(button => button.click());
@gsusI
gsusI / addopenwithcursor.ps1
Created August 31, 2023 08:39
Integrate the Cursor application into the context menu. Adds "Open folder with Cursor" and "Open with Cursor"
# Function to backup registry
Function BackupRegistry($backupPath) {
try {
reg export HKCU\Software\Classes $backupPath /y
Add-Content -Path $logPath -Value "Registry backup created at $backupPath."
}
catch {
Add-Content -Path $logPath -Value "Failed to backup registry. Error: $_"
throw
}
@gsusI
gsusI / twitter_scroll_capture.js
Created August 25, 2023 13:27
This Tampermonkey user script, named "Twitter Scroll Capture," is designed to capture tweets while scrolling on Twitter. When activated, it adds a "Start Recording" button to the Twitter page, allowing users to record tweets as they scroll through the feed. The captured tweets include details like text, username, handle, time published, URLs, co…
// ==UserScript==
// @name Twitter Scroll Capture
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Capture tweets while scrolling
// @author OpenAI
// @match https://twitter.com/*
// @grant none
// ==/UserScript==
class Car:
def __init__(self, spec, production_emission_ton_co2e, emission_per_km_ton, distance_per_year_km):
self.spec = spec
self.production_emission_ton_co2e = production_emission_ton_co2e
self.emission_per_km_ton = emission_per_km_ton
self.distance_per_year_km = distance_per_year_km
def annual_emission(self):
return self.emission_per_km_ton * self.distance_per_year_km
@gsusI
gsusI / Microsoft.PowerShell_profile.ps1
Last active May 20, 2023 11:56
Powershell script to save prompt and resulting command to history using GitHub Copilot CLI
function Invoke-CopilotWhatTheShell {
$TMPFILE = New-TemporaryFile;
try {
$wts_args = "(using powershell) $args)"
github-copilot-cli what-the-shell $wts_args --shellout $TMPFILE
if ($LASTEXITCODE -eq 0) {
if (Test-Path $TMPFILE) {
$FIXED_CMD = Get-Content $TMPFILE;
Add-Content -Value "$FIXED_CMD" -Path (Get-PSReadLineOption).HistorySavePath;
@gsusI
gsusI / .bashrc
Created April 30, 2023 08:27
Bash script to save prompt and resulting command to history using GitHub Copilot CLI
copilot_what-the-shell () {
history -s "?? $@"; # Save the prompt
TMPFILE=$(mktemp);
trap 'rm -f $TMPFILE' EXIT;
if /usr/bin/github-copilot-cli what-the-shell "$@" --shellout $TMPFILE; then
if [ -e "$TMPFILE" ]; then
FIXED_CMD=$(cat $TMPFILE);
history -s "$FIXED_CMD";
eval "$FIXED_CMD"
else
@gsusI
gsusI / convert-to-lf.ps1
Last active February 7, 2023 16:40
EOL from CRLF to LF recursively: this script will convert all files in the current directory and all subdirectories to unix line endings
# Set the parameters
$path = Get-Location
$numbOfThreads = 50
$exclude_patterns = "^.*(\.git|\.idea|node_modules|\.next|\.(jpeg|jpg|png|gif|mp4|mkv|mp3|wav)$).*$"
# Find filles to convert
$files = Get-ChildItem -Path $path -Recurse -Include * -File -Force | Where-Object {$_.FullName -notmatch $exclude_patterns}
Write-Host "Found $($files.Count) files"
$files | ForEach-Object -Parallel {
@gsusI
gsusI / style-embeds.css
Last active April 22, 2024 06:59
A number of classes to adjust the size and style of embeds in Obsidian.
/**
A number of classes to adjust the size and style of embeds in Obsidian.
`![[note|w-10%]]` - sets the width of the embed to 10% of the viewport width
`![[note|w-100px]]` - sets the width of the embed to 100 pixels
`![[note|h-10%]]` - sets the height of the embed to 10% of the viewport height
`![[note|h-100px]]` - sets the height of the embed to 100 pixels
@gsusI
gsusI / show-all-wikilocs-trails-on-map.js
Last active June 11, 2022 10:01
Script to run from the browser console whist on the Wikilocs maps page. It will display options to show all trails in the map
function showAllMaps() {
let xpath = "//*[contains(@class, 'trail-list__show-on-map') and contains(text(), 'Show on map')]";
let elements = document.evaluate(xpath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (let i = 0; i < elements.snapshotLength; i++) {
if (elements.snapshotItem(i).style.display == "none") {
continue;
}
let title = jQuery(elements.snapshotItem(i)).closest("h3");
console.log("Showing map for " + title.innerText);
elements.snapshotItem(i).click();