Deploying an old Supermodel site from an M-series Mac
For some of our older Supermodel sites you won't be able to run the deploy script successfully because the sites require and older version of Java. To fix this issue you need to tell the deploy to use Java 8 instead of whatever more current version you are running on your machine:
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
Convert images to an animated GIF
If you have ImageMagick installed you can use Terminal to convert a folder of images into an animated GIF. In Terminal, cd into the folder where your images are kept and then run the following script (modifying to suit):
convert -delay 10 -loop 0 *.png animated.gif
You can adjust the delay value to speed up or slow down the animation, and edit *.png to match your image naming/type (e.g it may be something like source-*.jpg). It can be a good idea to number your frame images to ensure proper ordering.
Note: the script above will layer each successive image on top of the previous, so if you are working with transparent images you may want to adjust it slightly so that the frame is wiped on each pass first:
convert -delay 10 -loop 0 *.png -set dispose background animated.gif
Combine images into an icon
Use Terminal to combine multiple PNG images into a single .ico icon file. Open Terminal, navigate into the folder containing the image files, then run this command:
convert 16.png 32.png 48.png 256.png favicon.ico
Note: since the most recent system update that uses ImageMagick 7 you now need to preface the command with 'magick' instead of 'convert':
magick 16.png 32.png 48.png 256.png favicon.ico
Depending on the colour profile of the PNG files you will sometimes get the error magick: Cannot write image with defined png:bit-depth or png:color-type. In this case you can add the -compress none option:
magick -compress none 16.png 32.png 48.png 256.png favicon.ico
Download a group of images
Use Terminal to download images from a group of URLs specified in a carriage-returned list within a text file. Open Terminal, navigate into the folder containing the text file, then run this command:
xargs -n1 curl -O textfilename
The above hasn’t always worked for me, but in those cases the following did the same trick:
cat textfilename | xargs -n 1 curl -O
Tell git to ignore changes
To tell git to ignore any current changes for a particular file, you can type the following command in Terminal (replacing $FILE with the name of the file):
git update-index --assume-unchanged $FILE
To reverse the change, you can alter the line as follows:
git update-index --no-assume-unchanged $FILE
Use Terminal to base64 encode an image
Generate base64 version of an image:
openssl base64 < path/to/file
Do the same, but remove line breaks:
openssl base64 < path/to/file.png | tr -d '\n'
Do the above, but copy the result to the clipboard:
openssl base64 < path/to/file.png | tr -d '\n' | pbcopy
Start a simple server from Terminal
As of macOS Monterey 12.3 Python 2 no longer comes pre-installed with the OS, so you will need to install Python 3 (brew install python) if not already installed. You can then run a simple server by navigating to the folder in terminal and entering:
python3 -m http.server 8080
You can change the port number at the end to avoid clashes with any other services running. For machines running Python 2 you can use this command:
python -m SimpleHTTPServer 8080
Imagemagick command to assemble images into a sprite
Change the dimensions and tile layout to suit the size of images and number of rows/columns you desire.
montage -background transparent -geometry 1500x344+0+0 -tile 4x13 *.png sprite3.png