Skip to content

Instantly share code, notes, and snippets.

View gsusI's full-sized avatar
💭
🛫

Jesus Iniesta gsusI

💭
🛫
View GitHub Profile
@gsusI
gsusI / Make WordPress to use protocol relative urls
Created January 8, 2019 16:40 — forked from lgg/Make WordPress to use protocol relative urls
Make WordPress to use protocol relative urls
//make other links relative
add_filter ('site_url', 'wp_make_theme_links_protocols_relative');
add_filter ('get_option_siteurl', 'wp_make_theme_links_protocols_relative');
add_filter ('stylesheet_directory_uri', 'wp_make_theme_links_protocols_relative');
add_filter ('template_directory_uri', 'wp_make_theme_links_protocols_relative');
add_filter ('wp_get_attachment_url', 'wp_make_theme_links_protocols_relative');
add_filter ('wp_get_attachment_thumb_url', 'wp_make_theme_links_protocols_relative');
add_filter ('the_permalink', 'wp_make_theme_links_protocols_relative');
function wp_make_theme_links_protocols_relative( $link ){
$link = str_replace("http://", "//", $link);
@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();
@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 / 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 / .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 / 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;
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 / 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==
@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
}