Skip to content

Instantly share code, notes, and snippets.

@bodja
bodja / antenna.py
Created December 17, 2020 20:52
Calculate antenna length
import argparse
import re
from fractions import Fraction
SPEED_OF_LIGHT = 300000000 # meters/second
class Frequency:
"""
Converts given frequency to Hertz (Hz)
@bodja
bodja / change-sdk.sh
Last active June 22, 2023 03:32
Download MacOSX SDK version and change minimum sdk version in info.plist
SDK_VERSION=$1
SDK_NAME="MacOSX${SDK_VERSION}.sdk"
TAR_FILE_NAME="${SDK_NAME}.tar.xz"
DOWNLOAD_URL="https://github.com/phracker/MacOSX-SDKs/releases/download/MacOSX10.11.sdk/${TAR_FILE_NAME}"
TAR_FILE_DEST="/tmp/${TAR_FILE_NAME}"
SDK_MIN_VERSION_FILE="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist"
SDK_DIR="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/"
echo Downloading $SDK_NAME
curl -L $DOWNLOAD_URL -o $TAR_FILE_DEST --progress-bar
@bodja
bodja / wtu.sh
Last active December 26, 2016 12:31
Update Winetricks of the WineskinWrapper
DESTINATION_FILE="/Users/$(id -un)/Library/Application Support/Wineskin/Wrapper/Wineskin-2.6.2.app/Wineskin.app/Contents/Resources/winetricks"
curl https://raw.githubusercontent.com/Winetricks/winetricks/master/files/LATEST \
-o $DESTINATION_FILE \
&& chmod +x $DESTINATION_FILE
@bodja
bodja / notes
Last active December 5, 2016 01:54
Build Wineskin engines using SDK 10.8
# W2.5.5v1EngineBase
1) put sdk 10.8 into the /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
2) change MinimumSDKVersion at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist to 10.8
3) update WineskinEngineBuilder's dependencies at /Users/<username>/Library/Application Support/Wineskin/EngineBase/W2.5.5v1EngineBase
libxml2 -> libxml2
libpng14 -> libpng16
derkey = Popen(['openssl', 'rsa', '-pubout', '-outform', 'DER', '-inform',
'PEM', '-in', path_to_pem_key], stdout=PIPE).stdout.read()
signature = Popen(['openssl', 'sha1', '-sha1', '-sign', path_to_pem_key,
zip_file.filename], stdout=PIPE).stdout.read()
with open('extension.crx', 'w') as crx:
crx.writelines(['Cr24',
struct.pack("<I", 2), # crx version
struct.pack("<I", len(derkey)),
struct.pack("<I", len(signature)),
derkey,
@bodja
bodja / show-hide-files.sh
Created April 23, 2015 08:56
Show/hide files on mac os x
show () {
if [ $(defaults read com.apple.finder AppleShowAllFiles) == NO ]; then
SHOW=YES
else
SHOW=NO
fi
defaults write com.apple.finder AppleShowAllFiles $SHOW
kill -1 `ps aucx | grep Finder | awk '{print $2}'`
}