Category: software-development

Software development is the process of conceiving, specifying, designing, programming, documenting, testing, and bug fixing involved in creating and maintaining applications, frameworks, or other software components. Software development involves writing and maintaining the source code, but in a broader sense, it includes all processes from the conception of the desired software through to the final manifestation of the software, typically in a planned and structured process. Software development also includes research, new development, prototyping, modification, reuse, re-engineering, maintenance, or any other activities that result in software products.

  • Nodejs MySQL and Handlebars boilerplate

    Node.js boilerplate with express, helmet, cors, xss-protection, mysql, session, cookie and express-handlebars view engine and many more..

    Well structured Node.js app. It uses mysql as database and express-handlebars as template and jest test package. It has bootstrap 4 integrated.
    Only two urls added for example * / for all users, * /my for all logged in user.

    Folder Structure

    Download or Clone it from github

    Spread the love
  • Install PHP 5.6 on macOS Catalina

    Install PHP 5.6 on macOS Catalina

    These steps worked on my Mac, Catalina version 10.15.3 (19D76).

    Step 1: Tap deprecated brew formula

    brew tap exolnet/homebrew-deprecated

    Step 2: Install PHP 5.6

    brew install [email protected]

    You can also have PHP 7.2 just run 

    brew install [email protected]

    Step 3: Install PHP switcher script to switch between 5.6 and 7.2

    $ curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw > /usr/local/bin/sphp 
    $ chmod +x /usr/local/bin/sphp

    If you run sphp 7.2 it should work but running sphp 5.6 will not work and will show error like this from apache.

    Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylibn  Referenced from: /usr/local/opt/[email protected]/lib/httpd/modules/libphp5.son  Reason: image not found

    Unless we switch openssl version, it wont work. So we have to install old openssl

    Step 4: Install old openssl

    brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb

    Step 5: Switch to openssl 1.0

    brew switch openssl 1.0.2t

    Now you switch to PHP 5.6 by 

    sphp 5.6

    Everything works.

    You can run these commands to check which version of openssl is being used in your mac.

    brew info openssl and brew info openssh

     

     

    Spread the love
  • SwiftUI Know When Entering Landscape Mode

    SwiftUI Know When Entering Landscape Mode

    Create a ObservableObject Object like this

    final class UserAndDeviceSettings: ObservableObject {
        @Published var userInterfaceOrientationChanges:Bool = false
        @Published var userInterfaceOrientationLandscape:Bool = false
    }

    Now go to your SceneDelegate and add a var on top and pass your settings var in UIHostingController in willConnectTo method.

    var settings = UserAndDeviceSettings()
    
    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).
    
            // Get the managed object context from the shared persistent container
            let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
    
            // Create the SwiftUI view and set the context as the value for the managedObjectContext environment keyPath
            let contentView = ContentView().environment(\.managedObjectContext, context)
    
            // Use a UIHostingController as window root view controller.
            if let windowScene = scene as? UIWindowScene {
                let window = UIWindow(windowScene: windowScene)
                
                // read the initial device orientation here
                self.settings.userInterfaceOrientationLandscape = (windowScene.interfaceOrientation.isLandscape == true)
                
                window.rootViewController = UIHostingController(rootView: contentView.environmentObject(self.settings))
                self.window = window
                window.makeKeyAndVisible()
            }
        }

    and in didUpdate delegate method, add this code.

    
    func windowScene(_ windowScene: UIWindowScene, didUpdate previousCoordinateSpace: UICoordinateSpace, interfaceOrientation previousInterfaceOrientation: UIInterfaceOrientation, traitCollection previousTraitCollection: UITraitCollection) {
            print(">> previous tratis  \(previousTraitCollection)")
            print(">> previous coordinateSpace \(previousCoordinateSpace)")
            print(">> previous orientation \(previousInterfaceOrientation)")
            
            self.settings.userInterfaceOrientationChanges = true
            
            if previousInterfaceOrientation == .portrait || previousInterfaceOrientation == .portraitUpsideDown {
                self.settings.userInterfaceOrientationLandscape = true
            } else {
                self.settings.userInterfaceOrientationLandscape = false
            }
        }

    Now you can use this @EnvironmentObject in any View

    @EnvironmentObject var settings:UserAndDeviceSettings
    
    if self.settings.userInterfaceOrientationLandscape {
        
    }
    Spread the love