Packaging apps
Packaging apps is useful for running apps on multiple machines without worrying about versions.
Here is a short guide on packaging Python apps, in 20 steps. It first involves “freezing” it using PyInstaller, then bundling it into an AppImage using AppImageKit’s appimagetool.
Concat to PDF
I wrote a script a few months ago to scrape web novels. I extracted
them as plaintext and saved every chapter. Since some books had over a
hundred chapters, I wanted to concatenate them so it would be easier to
read. Concatenation can be done quickly using cat
and tools
like pandoc
can generate pretty PDFs.
Overriding exit to tmux detach
I was using mosh like this:
function mssh {
echo "> mosh --no-init $1 -- tmux new-session -A -s main"
mosh --no-init $1 -- tmux new-session -A -s main
}
But sometimes I would enter exit
instead of tmux detach
and I would lose the session I had on the remote!
So I found this code block that I inserted into my remote ~/.bashrc
that would help me. It’s simple to read, if the session is not tmux, we exit, but if it is, check if it is desirable to preserve the session.
# also see https://medium.com/@toja/tip-using-mosh-with-scrollback-257a54a848b3
exit() {
if [[ -z $TMUX ]]; then
builtin exit
return
fi
panes=$(tmux list-panes | wc -l)
wins=$(tmux list-windows | wc -l)
count=$(($panes + $wins - 1))
if [ $count -eq 1 ]; then
tmux detach
else
builtin exit
fi
}
Note, pressing (CTRL+D) will still exit the session, if you want.
tags: code
Resolving changes overwritten
So I got this error the other day when I ran git pull
:
“Your local changes to the following files would be overwritten by
merge:” because my package.json
file was outdated.
I always keep git update-index --assume-unchanged
for my
package.json
so it was frustrating that git is trying to
overwrite it. (I know I could edit the .gitignore, but there are other
developers on this project.)
Anyway, in my heart of hearts, I knew that keeping the new
package.json
is probably better, so this is what I did:
git update-index --no-assume-unchanged package.json package-lock.json
git checkout -b k-localchanges1
git add -v .
git commit -m "message" # I'm backing up my copy of package.json into my local branch
git checkout development
git pull
rm -rf node_modules/
npm install
npx expo -c
tags: code