This is just the formatted version of the post originally created by Sarath Tamminana in Medium: Google Cloud Platform Command line cheat sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
} |
OlderNewer