Skip to content

Instantly share code, notes, and snippets.

View MarcoEidinger's full-sized avatar
🍫

Marco Eidinger MarcoEidinger

🍫
View GitHub Profile
@MarcoEidinger
MarcoEidinger / arc_fake_data.json
Last active February 12, 2020 00:51
arc_fake_data
{ "nodes": [
{ "id": 1, "name": "Onboarding", "n": 1, "grp": 1 },
{ "id": 2, "name": "Homepage", "n": 32, "grp": 2 },
{ "id": 3, "name": "Account List View", "n": 5,"grp": 3 },
{ "id": 4, "name": "Account Detail View", "n": 5, "grp": 3 },
{ "id": 5, "name": "Opportunity List View", "grp": 4 },
{ "id": 6, "name": "Opportunity Detail View", "grp": 4 },
{ "id": 7, "name": "Lead List View", "grp": 5 },
{ "id": 8, "name": "Lead Detail View", "grp": 5 },
{ "id": 9, "name": "Create Account", "grp": 3 },
@MarcoEidinger
MarcoEidinger / ExamplePreviewObjectTableViewCell.swift
Created June 6, 2020 15:07
Using Xcode Previews with SAP Cloud Platform SDK for iOS
import SAPFiori
class ProductObjectTableViewCell: FUIObjectTableViewCell {
required init() {
super.init()
self.detailImage = UIImage(named: "laptop")
self.headlineText = "Notebook Basic 15"
self.subheadlineText = "Notebooks"
self.footnoteText = "In Stock"
self.accessoryType = .detailDisclosureButton
@MarcoEidinger
MarcoEidinger / gist:6f62e45cca85ad4b6ae3b13c26dd444a
Created June 24, 2020 12:59
Run script for Aggregate target to create xcframework
# Release dir path
OUTPUT_DIR_PATH="${PROJECT_DIR}/XCFramework"
function archivePathSimulator {
local DIR=${OUTPUT_DIR_PATH}/archives/"${1}-SIMULATOR"
echo "${DIR}"
}
function archivePathDevice {
local DIR=${OUTPUT_DIR_PATH}/archives/"${1}-DEVICE"
@MarcoEidinger
MarcoEidinger / Demo.swift
Last active October 16, 2020 22:57
How-to access managed iOS Configuration with SAP Cloud Platform SDK for iOS
import SAPFoundation
// assuming a MDM/UEM provider pushed the following managed iOS configuration to device
// <plist version="1.0"><dict><key>UserEmailAddress</key><string>currentDeviceUser@company.com</string></dict></plist>
// get managed iOS configuration as dictionary
let managedConfigDic = ManagedConfigurationProvider().provideConfiguration().configuration
// access entry of managed iOS configuration
print("Value \(managedConfigDic["UserEmailAddress"]) equals 'currentDeviceUser@company.com' according to plist pushed by MDM/UEM provider")
@MarcoEidinger
MarcoEidinger / spm-dep-check.yml
Last active October 11, 2020 04:30
Workflow to periodically check for outdated Swift Package dependencies and then create a pull request to update them
name: Swift Package Dependencies
on:
schedule:
- cron: '0 8 * * 1' # every monday AM 8:00
jobs:
spm-dep-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@MarcoEidinger
MarcoEidinger / flatCompactMapForVariadicParameters.swift
Last active November 20, 2020 23:52
Variadic parameters are converted to an array while inside a function. Forwarding this array to another function which accepts variadic parameters will result in a nested array. Use this function to remove nesting arrays and remove nil values
extension Array where Element == Any {
/**
Variadic parameters are converted to an array while inside a function. Forwarding this array to another function which accepts variadic parameters will result in a nested array
Use this function to remove nesting arrays and remove nil values
```
var anyArray: [Any] = [[["Hello", nil]]
var result = anyArray.flatCompactMapForVariadicParameters() // result is ["Hello"]
```
*/
func flatCompactMapForVariadicParameters() -> [Any] {
@MarcoEidinger
MarcoEidinger / TableWithCodeTipsAndExamples.md
Last active April 27, 2024 22:41
Master GitHub markdown tables with code blocks

Master GitHub markdown tables with code blocks

  1. Use HTML tags to define the table to get the best layout result
  2. Use either backticks (```) or the HTML pre element with attribute lang
  3. Keep a blank line before and after a code block for correct formatting and syntax highlighting

Good

Example: nice looking table to show HTTP Responses

// ...
#if DEBUG
struct ObjectMessageView_Previews: PreviewProvider {
static var singleButtonPreview: some View {
ObjectMessageView(model: UIModelDataContent(text: "text1", list: nil, form: nil, picture: nil, video: nil,
header: UIModelDataHeader(title: UIModelDataValue(value: "A very long title which is maybe even too long but who knows :) who can really tell? I don't know. That is a real interesting question. What do you think?", dataType: UIModelData.ValueType.text.rawValue, rawValue: nil,
label: nil,
valueState: nil),
subtitle: UIModelDataValue(value: "A very long subtitle which is maybe even too long but who knows :) who can really tell
@MarcoEidinger
MarcoEidinger / MySchemeHandler.swift
Created August 24, 2021 00:17
Example for WKURLSchemeHandler implementation to replace custom url scheme with "https"
class MySchemeHandler: NSObject, WKURLSchemeHandler {
func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) {
print("started for \(urlSchemeTask.request.url?.absoluteString)")
guard let url = urlSchemeTask.request.url else { return }
var components = URLComponents(url: url, resolvingAgainstBaseURL: true)
components?.scheme = "https"
guard let finalUrl = components?.url else { return }
print("proxy to \(finalUrl.absoluteString)")
let task = URLSession.shared.dataTask(with: URLRequest(url: finalUrl)) { receivedData, urlresponse, error in
guard let response = urlresponse, let data = receivedData else { urlSchemeTask.didFinish(); return }
@MarcoEidinger
MarcoEidinger / Podfile
Last active September 4, 2021 22:19
Gists for "Rich and interactive cards in SwiftUI" blog post. Original: https://github.com/MarcoEidinger/ms-adaptivecards-ios-example
platform :ios, '14.0'
target 'MSAdaptiveCardExample' do
use_frameworks!
pod 'AdaptiveCards'
end