Skip to content

Instantly share code, notes, and snippets.

View bsorrentino's full-sized avatar

bsorrentino bsorrentino

View GitHub Profile
@bsorrentino
bsorrentino / Readme.md
Last active January 18, 2023 14:10
This extension lets us add the .if modifier to our Views and will only apply the modifiers we add if the condition is met.

SwiftUI Conditional

With this extension, we can add the .if() modifier to our View!

Example

struct ContentView: View {
    @State private var shouldAddShadow: Bool = true
@bsorrentino
bsorrentino / local-ipv4.mjs
Created September 15, 2022 08:50
get local ipv4 address in nodes
/**
* inspired by: https://github.com/IonicaBizau/local-ip-address
*
* @returns localIPv4 address
*/
function localIp4Address () {
const interfaces = Object.values(os.networkInterfaces())
for (let iface of interfaces) {
for (let alias of iface) {
if (alias.family === "IPv4"
@bsorrentino
bsorrentino / Enhance CLI with ZX.md
Last active May 2, 2022 12:34
Enhance CLI with ZX
@bsorrentino
bsorrentino / DynamicFetchRequestView.swift
Last active February 2, 2022 16:06
SwiftUI Dynamically Filtering FetchRequest
struct DynamicFetchRequestView<T: NSManagedObject, Content: View>: View {
// That will store our fetch request, so that we can loop over it inside the body.
// However, we don’t create the fetch request here, because we still don’t know what we’re searching for.
// Instead, we’re going to create custom initializer(s) that accepts filtering information to set the fetchRequest property.
@FetchRequest var fetchRequest: FetchedResults<T>
// this is our content closure; we'll call this once the fetch results is available
let content: (FetchedResults<T>) -> Content
@bsorrentino
bsorrentino / NestedObservableObject.swift
Last active January 17, 2023 07:34
SwiftUI: Property Wrapper for Nested ObservableObjects
//
// @ref https://www.swiftbysundell.com/articles/accessing-a-swift-property-wrappers-enclosing-instance/
// @Ref https://stackoverflow.com/a/58406402/521197
//
@propertyWrapper
struct NestedObservableObject<Value : ObservableObject> {
static subscript<T: ObservableObject>(
_enclosingInstance instance: T,
wrapped wrappedKeyPath: ReferenceWritableKeyPath<T, Value>,
@bsorrentino
bsorrentino / README.md
Last active August 2, 2021 16:08
Powerapps: Get field names and values from a Record ( ie. Translate a Record in a table name, value )

Abstract

This is a PowerApp Component Custom Function JsonToTable(json As String) -> Table that is able to transform a JSON Object in an equivalent PowerFx Table

Example

Considering the JSON below as input

 {
@bsorrentino
bsorrentino / App+Info.swift
Last active May 8, 2022 14:37
Swift Utilities for Xcode
//
// App+Version.swift
//
// Created by bsorrentino on 29/12/2019.
// Copyright © 2019 Bartolomeo Sorrentino. All rights reserved.
//
import Foundation
@bsorrentino
bsorrentino / pcfinit.yml
Last active March 24, 2021 23:02
Github Action - Scaffolds out your new PCF repo
#
# inspired by - https://github.com/rajyraman/pcf-template-dataset
#
name: pcf-init
on:
workflow_dispatch:
push:
branches: [master]
jobs:
@bsorrentino
bsorrentino / google.script.d.ts
Last active July 25, 2019 16:16 — forked from fjmorel/google.script.d.ts
Google Apps Script client-side Typescript definitions
// Google Apps Script methods available to scripts
declare namespace google {
/**
* Methods available to Google Apps Script
*/
namespace script {
interface IUrlLocation {
/**
* The string value of URL fragment after the # character, or an emptry string if no URL fragment is present
@bsorrentino
bsorrentino / README.md
Last active July 29, 2022 16:05
PlantUML Experience

PlantUML Experience

PlantUML in Docker

To install PlantUML for those platforms that do not provide its native packages see the following project [plantuml-install]

[PlantUML Hitchhikers Guide]

@[Crashedmind] wrote this guide as part of his own “Journey to Documentation as Code” using [PlantUML] as the main tools for proposing, analysing, documenting, maintaining software systems based on working with thousands of engineers across the globe.

Language