Skip to content

Instantly share code, notes, and snippets.

@kambala-decapitator
kambala-decapitator / fixXcodePlugins
Last active August 29, 2015 14:21
simple shell script to quickly add new UUID to custom Xcode plugins
#!/bin/bash
cd "${HOME}/Library/Application Support/Developer/Shared/Xcode/Plug-ins"
for plugin in *.xcplugin; do
/usr/libexec/PlistBuddy -c "Add :DVTPlugInCompatibilityUUIDs: string $1" "${plugin}/Contents/Info.plist"
done
import plistlib
# Read Plists
myAppInfoPlist = plistlib.readPlist(“MyApp/Info.plist”)
watchKitExtensionInfoPlist = plistlib.readPlist(“WatchKitExtension/Info.plist”)
watchKitAppInfoPlist = plistlib.readPlist(“WatchKitApp/Info.plist”)
# Update Watch Kit Extension Plist
watchKitExtensionInfoPlist[“NSExtension”][“NSExtensionAttributes”][“WKAppBundleIdentifier”] = watchKitAppInfoPlist[“CFBundleIdentifier”]
watchKitExtensionInfoPlist[“CFBundleVersion”] = myAppInfoPlist[“CFBundleVersion”]
@kambala-decapitator
kambala-decapitator / FSTraversal.m
Created April 16, 2018 09:48
Small macOS CLI program to list filesystem items
//
// main.m
// FSTraversal
//
// Created by Andrey Filipenkov on 03/03/17.
// Copyright © 2017 Andrey Filipenkov. All rights reserved.
//
@import Foundation;
@kambala-decapitator
kambala-decapitator / qrisk2015.cpp
Created April 16, 2018 09:56
Batch processing of health data using QRISK®2-2015 algorithm
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstring>
using std::string;
@kambala-decapitator
kambala-decapitator / gist:28e7666434e680a6e324d600cb76caab
Created June 13, 2019 07:29
objc code used to show screen properties of iOS device
- (void)viewDidLoad {
[super viewDidLoad];
__auto_type appLabel = [UILabel new];
appLabel.translatesAutoresizingMaskIntoConstraints = NO;
appLabel.text = NSBundle.mainBundle.executablePath.lastPathComponent;
[self.view addSubview:appLabel];
__auto_type createLabel = ^{
__auto_type l = [UILabel new];
@kambala-decapitator
kambala-decapitator / spaceWidth.swift
Created July 9, 2019 14:20
retrieve width of space character and compute how many spaces are required to fill the gap
let spaceWidth = { () -> Double in
let font = self.font!
var spaceGlyph = CGGlyph()
var space: UniChar = numericCast((" " as Unicode.Scalar).value)
_ = CTFontGetGlyphsForCharacters(font, &space, &spaceGlyph, 1)
return CTFontGetAdvancesForGlyphs(font, .horizontal, &spaceGlyph, nil, 1)
}()
// to be called from func layoutManager(_ layoutManager: NSLayoutManager, shouldSetLineFragmentRect lineFragmentRect: UnsafeMutablePointer<CGRect>, lineFragmentUsedRect: UnsafeMutablePointer<CGRect>, baselineOffset: UnsafeMutablePointer<CGFloat>, in textContainer: NSTextContainer, forGlyphRange glyphRange: NSRange)
let addSpaces = Int(Double(lineFragmentRect.pointee.maxX - lineFragmentUsedRect.pointee.maxX) / spaceWidth)
@kambala-decapitator
kambala-decapitator / sign_notarize_dmg.fish
Last active January 15, 2020 14:32
sign and notarize existing Kodi .dmg's
#!/usr/bin/env fish
set kodiRepo "$HOME/dev/kodi/macos"
set -x CODE_SIGN_IDENTITY "Developer ID Application: Kodi Foundation"
set DEV_ACCOUNT foo
set DEV_ACCOUNT_PASSWORD bar
set DEV_TEAM "QR7RHK8K4X"
# fixed params
set kodiVolume /Volumes/Kodi
@kambala-decapitator
kambala-decapitator / Fastfile
Last active September 27, 2023 07:32
fastlane: execute lanes from different platforms in a single lane
# https://github.com/fastlane/fastlane/issues/7676
desc "All App Store Connect"
lane :appStoreConnect do #|options|
self.runner.current_platform = :ios
appStoreConnect
self.runner.current_platform = :tvos
appStoreConnect
# the following executes before_all every time
@kambala-decapitator
kambala-decapitator / sign_kodi_darwin-embedded.sh
Last active April 8, 2020 09:14
bash script to sign iOS/tvOS Kodi
#!/usr/bin/env bash
# required:
# KODI_PATH - path to Kodi app that will be resigned, can be deb / ipa / app
# PROVISIONING_PROFILE - path to provisioning profile
# CODE_SIGN_IDENTITY - certificate name, e.g. 'iPhone Developer: ***'
# optional:
# OUT_DIR - where to save the resulting file
# PACKAGE_IPA - set to 1 to create .ipa file instead of plain .app
#!/bin/bash
showUsage() {
echo "usage: $(basename "$0") --app_identifier APP_ID --app_name APP_NAME [--group_name GROUP_NAME] [--username USERNAME] [--team_id TEAM_ID] [--team_name TEAM_NAME]"
}
if [[ $# -eq 0 ]]; then
showUsage
exit 1
fi