Skip to content

Instantly share code, notes, and snippets.

View krzyspmac's full-sized avatar

Krzysztof Pawłowski krzyspmac

View GitHub Profile
@krzyspmac
krzyspmac / vector.lua
Created September 10, 2022 19:27 — forked from Rapptz/vector.lua
local vector = {}
vector.__index = vector
local function is_vector(t)
return getmetatable(t) == vector
end
function vector.new(x, y)
return setmetatable({ x = x or 0, y = y or 0 }, vector)
end
setenv_x86_mac()
{
export CFLAGS="-arch x86_64 -no-cpp-precomp"
}
setenv_arm_mac()
{
export CFLAGS="-arch arm64 -no-cpp-precomp"
}
@krzyspmac
krzyspmac / booklet_page_counter.py
Last active January 23, 2022 12:23
Print rearranged page counts to reflect the order of the pages when printed as booklets of 3, double sided, sheets
# Booklet of counter of sheets
booklet_sheet_count = 3
booklet_package_page_count = booklet_sheet_count * 2 * 2
pages = sys.argv[1:]
if len(pages) % booklet_package_page_count != 0:
sys.stderr.write("Page count of PDF needs to be a multiple of " + str(booklet_run_count) + ".\n")
sys.stderr.write("You can append blank pages using Preview if needed. Select the last page and choose 'Edit > Insert > Blank Page'.\n")
sys.exit(1)
@krzyspmac
krzyspmac / Parameters.py
Created January 28, 2015 10:22
Basic Python Command Line Parameter Parser
#!/usr/bin/python
import getopt
import os, sys
path = False
#
# usage
#
def usage():
@krzyspmac
krzyspmac / md5.sh
Created January 27, 2015 15:19
Calculate correct MD5 from MacOS X Terminal without newline inserted by the terminal
# Calculate the md5 of the word "grape" (without quotes)
echo -n grape | md5
@krzyspmac
krzyspmac / Deserialize.m
Created January 27, 2015 12:28
Serialize and deserialize PLIST to/from NSDictionary
// PLIST in NSData to NSDictionary
NSDictionary * result = [NSPropertyListSerialization propertyListWithData:data options:0 format:&format error:outError];
@krzyspmac
krzyspmac / MakeReleaseDMG.sh
Created January 27, 2015 12:12
Create distribution DMG with application, link to /Applications folder and backdrop image in MacOS X.
#!/bin/bash
# This script needs to have specific folders set. See the code below.
if [[ -z "$2" ]]; then
echo >&2 "MakeReleaseDMG creates a release disk image ready to be uploaded to the server."
echo >&2 "Remember to turn on Support for Assistive Devices in Universal Control"
echo >&2 "MakeReleaseDMG <Xcode archive path> <output dmg path>"
exit 1
fi