Skip to content

Instantly share code, notes, and snippets.

View iCross's full-sized avatar
🚀
Solving problems with efficiency.

Lukas iCross

🚀
Solving problems with efficiency.
  • autonomad
  • Taiwan
  • 15:05 (UTC +08:00)
View GitHub Profile
@iCross
iCross / template.bash
Created May 15, 2023 11:38
Optimizing Your Bash Scripts: An Advanced Template and Its Key Features. MIT license.
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
if [[ "${DEBUG-0}" == "1" ]]; then
set -o xtrace
fi
@iCross
iCross / heic.zsh
Last active May 14, 2023 15:54
One of my favorite zsh functions allows me to effortlessly upload .HEIC photos from my iPhone to macOS and automatically convert them to .jpg format. Furthermore, I can then utilize mozjpeg to compress the images, optimizing their size without compromising quality. MIT License.
function heic () {
for f in *.HEIC
do
[[ -e $f ]] || { echo "Error: File $f does not exist"; continue; }
output_file=${f:t:r}.jpg
/opt/homebrew/bin/convert -format jpg "$f" "$output_file" && \
/opt/homebrew/bin/trash "$f" || \
echo "Error: Conversion with convert failed for $f"
original_size=$(du -h "$output_file" | cut -f1)
tmp_file=$(mktemp /tmp/moz.XXXXXX.jpg)
@iCross
iCross / brew_cleanup.sh
Last active March 26, 2023 01:11
brew upgrade and cleanup
alias brew_cleanup="brew update && brew outdated --verbose && brew upgrade && brew cleanup -s --prune=all && brew cleanup && brew autoremove --dry-run"
# brew autoremove
ssh-keygen -R github.com
mv ~/.ssh/known_hosts.old /tmp/
http https://api.github.com/meta | jq -r '.ssh_keys[] | ("github.com " + .)' >> ~/.ssh/known_hosts
ssh -vT git@github.com
// ==UserScript==
// @name Google Link Cleaner
// @description Prevents Google from being informed about each click on a result link.
// @include http://www.google.*/
// @include http://www.google.*/?*
// @include http://www.google.*/#*
// @include http://www.google.*/search*
// @include http://www.google.*/webhp*
// @include https://www.google.*/
// @include https://www.google.*/?*
@iCross
iCross / gist:962492d456afc0601b2f
Created February 4, 2015 15:48
google link cleaner
for (var i = 0; i < document.links.length; i++) {
document.links[i].removeAttribute('onmousedown');
}
javascript:(function()%7Bfor%20(var%20i%20%3D%200%3B%20i%20%3C%20document.links.length%3B%20i%2B%2B)%20%7Bdocument.links%5Bi%5D.removeAttribute('onmousedown')%3B%7D%7D)()
@iCross
iCross / gist:f1c2824d3861ee7d86ad
Created January 19, 2015 07:57
Bookmarklet: copy url and title
javascript:prompt("URL and title:", document.location.href +' ( '+ document.title+' )');void(0)
@iCross
iCross / gist:8bf0857125f4e8cfcacb
Created January 19, 2015 07:06
Bookmarklet: Copy url and title in markdown format
javascript:prompt("URL and title:", '['+document.title +']' +'('+document.location.href+')');void(0)
--- This will take a url on your clipboard, and use google to shorten it
--- create a new text expander item, set to applescript and paste this in.
--- set your google developer api key :
set myKey to "XXXXXXXXXXXXXXXXXXXXXXXXXX"
set the ClipURL to (the clipboard as string)
ignoring case
if ((characters 1 through 4 of ClipURL as string) is not "http") then