Skip to content

Instantly share code, notes, and snippets.

View lordlycastle's full-sized avatar
🤙
Let it Fly!

lordlycastle

🤙
Let it Fly!
View GitHub Profile
@lordlycastle
lordlycastle / update_refs failed.sh
Last active May 13, 2025 09:34
When you get update_ref failed for ref error in git.
# Rename from 'C:/Users/Repos/phishfoodvr/.git/refs/remotes/origin/CHA/main.lock' to 'C:/Users/Repos/phishfoodvr/.git/refs/remotes/origin/CHA/main' failed. Should I try again? (y/n) n
# error: update_ref failed for ref 'refs/remotes/origin/CHA/main': couldn't set 'refs/remotes/origin/CHA/main'
$ cd $(git rev-parse --show-toplevel) # if necessary
$ rm -rf .git/refs/remotes/origin # remove all origin/*
$ mkdir .git/refs/remotes/origin # create empty origin/
$ git fetch origin # repopulate origin/*

When you have a window that is a system dialog, or alert, type of window, and you do not know which application it belongs to, you can try using code such as the following example AppleScript code to determine the name of the application to which it belongs:

tell application "System Events" to ¬
	get name of every application process ¬
		whose role description of window 1 is "system dialog"

Or:

tell application "System Events" to ¬

Thanx, that helped me a lot while I was migrating from BitBucket to AWS CodeCommit. Some helpful hints:

  • commit & push everything
  • remove hooks git lfs uninstall
  • remove lfs stuff from .gitattributes
  • list lfs files using git lfs ls-files | sed -r 's/^.{13}//' > files.txt
  • run git rm --cached for each file while read line; do git rm --cached "$line"; done < files.txt
on run input
tell application "Finder"
set tracksFolder to folder (POSIX file "/Users/<username>/Documents/tor.Downloads/Antennas To Hell")
set songs to files in tracksFolder
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {" "}
repeat with song in songs
if name extension of song is "mp3" then
set fileName to name of song as text
set trackNum to text item 1 of fileName
tell application "Finder"
set src to folder (POSIX file "/Users/<username>/Library/Containers/com.kuvva.Kuvva-Wallpapers/Data/Library/Application Support/Kuvva")
set des to folder (POSIX file "/Users/<username>/Dump Truck/Kuvva")
set wallpapers to name of files of src
set saved to name of every file of (entire contents of des)
-- delay 10.0
tell me to set ctgry to «event ScTlplsL» (file "Macintosh HD:Users:<username>:Library:Containers:com.kuvva.Kuvva-Wallpapers:Data:Library:Preferences:com.kuvva.Kuvva-Wallpapers.plist")
set artist to LastArtistAnnouncement of ctgry
if (exists folder ((des as text) & artist as text)) = false then
tell application "Finder"
set tnconf to alias "Macintosh HD:Users:<username>:Library:Application Support:Tunnelblick:Configurations:"
set sharedtnconf to alias "Macintosh HD:Library:Application Support:Tunnelblick:Shared:"
set allconf to alias "Macintosh HD:Users:<username>:Downloads:config:"
set alltnconfs to name of files of tnconf & name of files of sharedtnconf
set allconfs to name of files of allconf
try
set dest to folder "tempConfFiles" of desktop
on error
set dest to make new folder at desktop with properties {name:"tempConfFiles"}
tell application "Finder"
set selected to selection
set current_folder to item 1 of selected
set mlist to every file of current_folder
repeat with this_file in mlist
set cur_ext to name extension of this_file
set new_name to text 1 thru -((length of cur_ext) + 2) of (name of this_file as text)
set new_folder to make new folder with properties {name:new_name} at current_folder
move this_file to new_folder
end repeat
@lordlycastle
lordlycastle / Click Allow.applescript
Last active May 19, 2020 17:38
Clicks allow on the front most window.
tell application "System Events"
repeat while exists (processes where name is "SecurityAgent")
tell process "SecurityAgent"
click button "Allow" of window 1
end tell
delay 0.2
end repeat
end tell
@lordlycastle
lordlycastle / Create Disk Image.applescript
Last active September 27, 2024 18:28
This AppleScript creates a disk image (.dmg) with the given files/folders user provides.
set fileType to display dialog "Create disk image of a " buttons {"Folder", "File", "Cancel"} ¬
default button ¬
"Folder" cancel button ¬
"Cancel" with title "Create Disk Image"
if button returned of fileType is "Folder" then
set input to choose folder with prompt "Choose folder to make disk image of:"
else if button returned of fileType is "File" then
set input to choose file with prompt "Choose file to make disk image of:"
end if
@lordlycastle
lordlycastle / ipython_notebook_in_git.md
Created May 14, 2020 17:38 — forked from pbugnion/ ipython_notebook_in_git.md
Keeping IPython notebooks under Git version control

This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.

To use the script, follow the instructions given in the script's docstring.

For further details, read this blogpost.

The procedure outlined here is inspired by this answer on Stack Overflow.