Skip to content

Instantly share code, notes, and snippets.

View mmackh's full-sized avatar

Maximilian Mackh mmackh

View GitHub Profile
@mmackh
mmackh / gist:9049038
Created February 17, 2014 11:35
KNX Write Protocol
- (void)changeStatusOfObject:(PCHousemasterObject *)object toValue:(float)value
{
NSArray *groupAddressArray = [object.groupAddress componentsSeparatedByString:@"/"];
NSString *groupAddressBaseTwo = [NSString stringWithFormat:@"%@%@%@",[self convertToBinary:[groupAddressArray[0] integerValue] padding:5],[self convertToBinary:[groupAddressArray[1] integerValue] padding:3],[self convertToBinary:[groupAddressArray[2] integerValue] padding:8]];
NSString *groupAddressDecimal = [NSString stringWithFormat:@"%ld",strtol([groupAddressBaseTwo UTF8String], NULL, 2)];
NSString *message = [NSString stringWithFormat:@"1|%@|%i\0",groupAddressDecimal,(int)(value * 100)];
NSLog(@"%@",message);
import BaseComponents
class LayoutViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.addSplitView { splitView in
splitView.addSplitView(configurationHandler: { splitView in
splitView.direction = .horizontal
@mmackh
mmackh / PasteboardHelper.h
Last active April 4, 2022 07:58
PasteboardHelper - Load .eml files from Mail.app (macOS)
//
// PasteboardHelper.h
// Spaceboard
//
// Created by mmackh on 28.03.22.
//
#import <Foundation/Foundation.h>
@class PasteboardHelperPromiseResolveRequest;
@mmackh
mmackh / woocommerce_extension.php
Last active July 8, 2021 08:51
Role Based Pricing - Manual Order
function woocommerce_ajax_add_order_item_meta( $item_id, $raw_item, $order ) {
$product = $raw_item->get_product();
$rolePrices = $product->get_meta('_role_based_price' );
if (!$rolePrices) return;
$userRole = array_shift($order->get_user()->roles);
if (!isset($rolePrices[$userRole])) return;
$grossPrice = $product->get_price_including_tax();
$netPrice = $product->get_price_excluding_tax();
  1. Created an iFrame on the product page with the content 'Loading...' to adjust the styling to fit the page
  2. Added iFrame to top of product page on Mobile, adjusted properties to collapsed & hidden on page load
  3. Added custom JS code that will check if: Mobile, Product Page URL contains appropriate model substring.
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';

$w.onReady(function () {
@mmackh
mmackh / IPDFContextMenu.h
Last active May 31, 2020 23:55
NSMenu in Catalyst
//
// IPDFContextMenu.h
// InstaPDF
//
// Created by Maximilian Mackh on 02/02/15.
// Copyright (c) 2015 mackh ag. All rights reserved.
//
#import <Foundation/Foundation.h>
@mmackh
mmackh / delegate.m
Last active October 29, 2019 14:39
Catalyst - NSToolbar Search
static NSString * toolbarIdentifierSearch = @"Search";
@interface IPDFToolbarItem : NSToolbarItem
@property (atomic,readwrite) id view;
@property CGSize minSize;
@property CGSize maxSize;
@end
@mmackh
mmackh / PCWebView.h
Last active April 13, 2017 09:48
PCWebView
//
// PCWebView.h
//
// Created by Maximilian Mackh on 25/03/2017.
// Note this Open Source class relies on PCSplitView.h found on Github
#import <UIKit/UIKit.h>
@interface PCWebView : UIView
@mmackh
mmackh / NSString+Additions.h
Last active January 19, 2017 23:12
Personal NSString Additions
//
// NSString+Hash.h
// Orbitink
//
// Created by mmackh on 5/3/13.
// Copyright (c) 2013 Professional Consulting & Trading GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
@mmackh
mmackh / NSObject+Notifications.h
Last active December 23, 2015 09:39
NSObject category for an NSNotificationCenter abstraction to keep your code clean & lean.
//
// NSObject+Notifications.h
// InstaPDF
//
// Created by Maximilian Mackh on 18/09/13.
// Copyright (c) 2013 mackh ag. All rights reserved.
//
#import <Foundation/Foundation.h>