Joseph Michael Pesch
VP Programming

Powershell Script to set full access to folders in Windows

by 28. May 2022 18:30

Powershell Script to set full access to folders in Windows:

 

$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("user_name","FullControl","Allow")

function Get-Folders {

    param($path)

    $list = ''

    $comma = ""

    foreach ($folder in Get-ChildItem -Path $path -Recurse -Directory) {

        Write-Output $folder.FullName

        $ACL = Get-ACL -Path $folder.FullName

        $ACL.SetAccessRule($AccessRule)

        $ACL | Set-Acl -Path $folder.FullName

        Get-Folders $folder.FullName

    }

}

Get-Folders 'C:\ProgramData\Docker'

Tags:

Windows

XCode - Add AppDelegate.swift and SceneDelegate.swift to SwiftUI Application

by 13. March 2021 13:42

Step 1) Comment out (or remove) the @main code entry point (example below).

@main

structiDineApp: App {

    @StateObject var order = Order()

 

    var body: some Scene {

        WindowGroup {

            MainView()

                .environmentObject(order)

        }

    }

}

Step 2) Add entry shown below to info.plist

<key>UIApplicationSceneManifest</key>

<dict>

    <key>UIApplicationSupportsMultipleScenes</key>

    <false/>

    <key>UISceneConfigurations</key>

    <dict>

        <key>UIWindowSceneSessionRoleApplication</key>

        <array>

            <dict>

                <key>UISceneConfigurationName</key>

                <string>Default Configuration</string>

                <key>UISceneDelegateClassName</key>

                <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>

            </dict>

        </array>

    </dict>

</dict>

Step 3) Add AppDelegate.swift

import Foundation

import UIKit

 

@UIApplicationMain

classAppDelegate: UIResponder, UIApplicationDelegate {

 

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        // Override point for customization after application launch.

        returntrue

    }

 

    // MARK: UISceneSession Lifecycle

 

    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {

        // Called when a new scene session is being created.

        // Use this method to select a configuration to create the new scene with.

        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)

    }

 

    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {

        // Called when the user discards a scene session.

        // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.

        // Use this method to release any resources that were specific to the discarded scenes, as they will not return.

    }

 

}

Step 4) Add SceneDelegate.swift

import UIKit

import SwiftUI

 

classSceneDelegate: UIResponder, UIWindowSceneDelegate {

 

    var window: UIWindow?

 

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.

        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.

        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).

 

        // Create the SwiftUI view that provides the window contents.

        let contentView = ContentView()

 

        // Use a UIHostingController as window root view controller.

        if let windowScene = scene as? UIWindowScene {

            let window = UIWindow(windowScene: windowScene)

            window.rootViewController = UIHostingController(rootView: contentView)

            self.window = window

            window.makeKeyAndVisible()

        }

    }

 

    funcsceneDidDisconnect(_ scene: UIScene) {

        // Called as the scene is being released by the system.

        // This occurs shortly after the scene enters the background, or when its session is discarded.

        // Release any resources associated with this scene that can be re-created the next time the scene connects.

        // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).

    }

 

    funcsceneDidBecomeActive(_ scene: UIScene) {

        // Called when the scene has moved from an inactive state to an active state.

        // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.

    }

 

    funcsceneWillResignActive(_ scene: UIScene) {

        // Called when the scene will move from an active state to an inactive state.

        // This may occur due to temporary interruptions (ex. an incoming phone call).

    }

 

    funcsceneWillEnterForeground(_ scene: UIScene) {

        // Called as the scene transitions from the background to the foreground.

        // Use this method to undo the changes made on entering the background.

    }

 

    funcsceneDidEnterBackground(_ scene: UIScene) {

        // Called as the scene transitions from the foreground to the background.

        // Use this method to save data, release shared resources, and store enough scene-specific state information

        // to restore the scene back to its current state.

    }

 

}

 

 

Tags:

Swift | XCode

XCode - Tab Bar View Controller - Add Tab View

by 13. March 2021 11:58

To add an additional tab view:

  1. Add new View Controller to storyboard
  2. CTRL + Drag from the Tab Bar Controller (top left icon) to the new View Controller
  3. Select "View Controller" from the Segue dialog window

Tags:

XCode

XCode Hangs on Startup

by 1. November 2020 15:13

Try deleting this directory:

~/Library/Saved Application State/com.apple.dt.Xcode.savedState/

Tags:

XCode

Image Test

by 11. September 2020 06:50

Tags:

Chrome Browser Default Color Blue looks like Purple

by 30. June 2020 09:08

Go to chrome://flags and set the "Force color profile" to sRGB

Tags:

SQL Server on Mac via Docker to Support .Net SQL Based Project

by 5. May 2020 17:50

To run SQL server on Mac using Docker, follow the steps below.

  1. Download, Install and Run the Docker Desktop Application for Mac: https://hub.docker.com/editions/community/docker-ce-desktop-mac/
  2. Open Terminal window and run the following statements:
    1. sudo docker pull mcr.microsoft.com/mssql/server:2019-CU3-ubuntu-18.04

    2. sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD={PASSWORD_HERE}" -p 1433:1433 --name sqlserver -d mcr.microsoft.com/mssql/server:2019-CU3-ubuntu-18.04

    3. docker ps (to see running processes, or use the desktop application dashboard)

To initialize the SQL for .Net project:

  1. Create the following folder if it doesn't already exist: Users/{username}/.microsoft/usersecrets
  2. dotnet user-secrets init
  3. dotnet ef migrations script -i -o migration.sql
  4. dotnet dev-certs https --trust

VS Code Extensions:

  1. ms-dotnettools.csharp
  2. ms-mssql.mssql
  3. esbenp.prettier-vscode
  4. dbaeumer.vscode-eslint

Tags:

Mac OS | SQL Server

NgCore - Angular App with Dot Net Core

by 8. September 2019 12:57

Before getting started, I recommend looking at using https://cmder.net/ for Command Editor.  

Prerequisites:

  1. Angular installed globally: 
    npm install -g @angular/cli
  2. Visual Studio Code or Visual Studio Community (or other full version)
  3. Node.js v. 8.10.0 or higher (https://nodejs.org/en/download/) to check current version, run command: 
    node -v

Steps to create project:

  1. Create folder for the project, in my case "NgCore"
  2. Run the following command from within the project folder:  
    ng new NgCoreApp
  3. Run the following command from withing the "NgCoreApp" folder: 
    ng build
  4. Run the app from the "dist" folder (created by the "ng build")

Tags:

Angular | ASP.Net Core

https://cmder.net/

by 8. September 2019 12:54

Tags:

Tools

https://codechecks.io/

by 6. September 2019 06:20

Tags:

MacBook SSD Upgrade

by 28. August 2019 11:36

Tags:

Mac OS

HTML Textbox Auto Complete

by 15. August 2019 19:44

Tags:

HTML

Postman Collection Runner Save Response Body to Environment Variable

by 9. August 2019 08:14

First, create an environment variable called responseData, with the value [].

Then, add the following code under 'Tests' in Builder. Postman environment variables are intended to be used as string, so we will parse the object then push the JSON responses from the API into the object array.

var jsonData = JSON.parse(responseBody); var old = pm.environment.get("responseData"); old = JSON.parse(old); // filter jsonData if needed

old.push(jsonData); old = JSON.stringify(old); pm.environment.set("responseData", old); console.log(pm.environment.get("responseData")); Now you can retrieve a nested JSON object with all the response data included by viewing the environment variables value (see example below).

Warning: you must reset the responseData value as [] after every use of Collection Runner in order to avoid keeping data from previous runs.

Tags:

ffmpeg

by 21. May 2019 12:40

Tags:

Python Async without Await

by 19. May 2019 16:26

import asyncio
import time
 
async def px(x):
    time.sleep(5)
    print(x + ': ' + str(time.time()))
 
async def main():
    x = px('x')
    print("main1")
    y = px('y')
    print("main2")
    asyncio.ensure_future(y)
    asyncio.ensure_future(x)
 
asyncio.run(
    main())
    
input()

Tags:

Python

Google GSuite Drive File Stream

by 19. May 2019 10:12

 

Local Cache Location:

  • Win: %USERPROFILE%\AppData\Local\Google\DriveFS
  • Mac: ~/Library/Application Support/Google/DriveFS

Tags:

GSuite

Swift IOS UITableViewCell Button

by 5. January 2019 12:40

There are two steps to add a working button to a table view cell. The first step is to add a button like this:

cell.accessoryType = .detailDisclosureButton

The second step is to take action when the button is tapped by creating the accessoryButtonTappedForRowWith method:

override func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) {
    doSomethingWithItem(indexPath.row)
}

Tags:

XCode | iOS | Swift

xCode Support for IOS Device

by 24. November 2018 06:47

Trying to run xCode against connected iPhone and receive error message below:

Could not locate device support files. This iPhone 6s Plus is running iOS 12.0.1 (16A404), which may not be supported by this version of Xcode.

 

Download latest xCode from developer.apple.com (as .xip file), extract the .app file (https://developer.apple.com/download/more/)

Right click on latest xCode .app and select "Show Package Contents" and navigate to:

/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport

Select the required version(s) and copy to:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport

Look into this path as well: /Users/xxx/Library/Developer/Xcode/iOS DeviceSupport

Tags:

XCode

xCode Facebook Login Integration Using CocoaPods

by 18. November 2018 09:26

Terminal window, navigated to root folder where xCode project exists and run the following commands:

  • $ sudo gem install cocoapods
  • $ pod init

This will create a file named Podfile in your project's root directory. Open the Podfile with a text editor and add the following:

  • pod 'FBSDKLoginKit'

Back in the Terminal window, run the following command:

  • $ pod install 

Register app with Facebook (follow steps in this link: https://developers.facebook.com/docs/facebook-login/ios/)

Configure the information property list file (info.plist) with an XML snippet that contains data about your app. Right-click info.plist, and choose Open As Source Code. Copy and paste the following XML snippet into the body of your file ( ...)

<key>CFBundleURLTypes</key>
<array>
  <dict>
  <key>CFBundleURLSchemes</key>
  <array>
    <string>fb[APP_ID]</string>
  </array>
  </dict>
</array>
<key>FacebookAppID</key>
<string>[APP_ID]</string>
<key>FacebookDisplayName</key>
<string>[APP_NAME]</string>

To use any of the Facebook dialogs (e.g., Login, Share, App Invites, etc.) that can perform an app switch to Facebook apps, your application's info.plist also needs to include:

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>fbapi</string>
  <string>fb-messenger-share-api</string>
  <string>fbauth2</string>
  <string>fbshareextension</string>
</array>

Go to the Project Navigator in Xcode and select your project to see project settings. Select Other Linker Flags for editing. Add the flag -ObjC to Other Linker Flags for all build targets. NOTE: Use the find feature to easily locate the Other Linker Flags in the settins area.

If you still have the xCode project open close it. Open the new Workspace that should have been created in the same root folder as the project (e.g. MyApp.xcodeproj should now have a MyApp.xcworkspace partner).

Update the applications AppDelegate method to include the FBSDKLoginKit import reference and methods with FBSDKApplicationDelegate and FBSDKAppEvents (sample shown below).

import UIKit
import FBSDKLoginKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        // FaceBook
        return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    }
    
    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.

        // FaceBook
        FBSDKAppEvents.activateApp()
    }
    
    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
    }


    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }


}

Build Project for Running to make sure everything compiles correctly.

 

Tags:

Facebook | XCode

Hosted Site Issues with Roslyn - This program is blocked by group policy. For more information, contact your system administrator

by 9. September 2018 12:24
NOTE: Had to remove package: Microsoft.CodeDom.Providers.DotNetCompilerPlatform
      Due to hosting limitation, throwing this error:
      This program is blocked by group policy. For more information, contact your system administrator
      Cannot execute a program. The command being executed was 
          "C:\InetPub\...\bin\roslyn\csc.exe" 
              /shared /keepalive:"10" /noconfig  
              /fullpaths @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\bd40b76f\3452b533\33n50imf.cmdline"
       
NOTE: See nuget url for package details:
      https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform
       
NOTE: Some of the new C# 6.0 language features if used in Views (MVC project) will not compile. 
      Many of my views use the ? null checking operator for accessing Model properties.  
      All of these views now return errors on my Godaddy hosted MVC 5 application.
      This error occurs because Views (by default) are compiled at runtime using the .NET pipeline (not pre-compiled).
      To resolve this issue, simply uncheck the "Allow precompiled site to be updatable" option in your publish profile settings.  
      This should pre-compile your views and allow your C# 6.0 (Latest version of Roslyn Compiler) to run like a champ.

Tags:

MVC