Skip to content

Instantly share code, notes, and snippets.

Andrey Filipenkov kambala-decapitator

Block or report user

Report or block kambala-decapitator

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kambala-decapitator / spaceWidth.swift
Created Jul 9, 2019
retrieve width of space character and compute how many spaces are required to fill the gap
View spaceWidth.swift
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 / gist:28e7666434e680a6e324d600cb76caab
Created Jun 13, 2019
objc code used to show screen properties of iOS device
View gist:28e7666434e680a6e324d600cb76caab
- (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 / qrisk2015.cpp
Created Apr 16, 2018
Batch processing of health data using QRISK®2-2015 algorithm
View qrisk2015.cpp
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstring>
using std::string;
kambala-decapitator / FSTraversal.m
Created Apr 16, 2018
Small macOS CLI program to list filesystem items
View FSTraversal.m
// main.m
// FSTraversal
// Created by Andrey Filipenkov on 03/03/17.
// Copyright © 2017 Andrey Filipenkov. All rights reserved.
@import Foundation;
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 / fixXcodePlugins
Last active Aug 29, 2015
simple shell script to quickly add new UUID to custom Xcode plugins
View fixXcodePlugins
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"
You can’t perform that action at this time.