Snippets Collections
//  Reachability.swift
//  Vital
//  Created by Mac HD on 30/01/2023.

import SystemConfiguration

public class Reachability {

    class func isConnectedToNetwork() -> Bool {

        var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
        zeroAddress.sin_len = UInt8(MemoryLayout.size(ofValue: zeroAddress))
        zeroAddress.sin_family = sa_family_t(AF_INET)

        let defaultRouteReachability = withUnsafePointer(to: &zeroAddress) {
            $0.withMemoryRebound(to: sockaddr.self, capacity: 1) {zeroSockAddress in
                SCNetworkReachabilityCreateWithAddress(nil, zeroSockAddress)

        var flags: SCNetworkReachabilityFlags = SCNetworkReachabilityFlags(rawValue: 0)
        if SCNetworkReachabilityGetFlags(defaultRouteReachability!, &flags) == false {
            return false

        /* Only Working for WIFI
        let isReachable = flags == .reachable
        let needsConnection = flags == .connectionRequired

        return isReachable && !needsConnection

        // Working for Cellular and WIFI
        let isReachable = (flags.rawValue & UInt32(kSCNetworkFlagsReachable)) != 0
        let needsConnection = (flags.rawValue & UInt32(kSCNetworkFlagsConnectionRequired)) != 0
        let ret = (isReachable && !needsConnection)

        return ret

    func checkInternetConnection() {
        let internetConnected = Reachability.isConnectedToNetwork()
        if !internetConnected {
            print("no internet")
            self.showToast(message: "no internet")
# ssh-copy-id takes care of adding your key in the right place

ssh-copy-id -i " -p2222"

# If you don't use -i all of your public keys will be copied over.
# Also a alias for the host can be used if configured in your ssh config.

# You will be asked for the password and after that all should be taken care of.
# There are a few ways to change the url in wordpress

# The prefered method is the wp-cli via search-replace.
$ wp search-replace 'http://example.test' '' --skip-columns=guid

# You can also test with a dry run
$ wp search-replace 'foo' 'bar' wp_posts wp_postmeta wp_terms --dry-run

# If the wp-cli is not available or you can't use SSH there are three other ways to try inside the files wp-config and functions.php

# At the beginning of wp-config.php, add
define( 'WP_HOME', '' );
define( 'WP_SITEURL', '' );

# At the end of the file, before the comment to stop editing here, you can set the relocate method. This always takes the current url calling "/wp-login.php" as slug as site url.

# Inside funcions.php, as first call, you can set
update_option( 'siteurl', '');
update_option( 'home', '');

# Use Plugin

The plugin 'Better search replace' is also able to change the links in the database quite easily.

# As last resort, you can change the database values manually.You will have to look for "siteurl" in the table "wp_options" and change the values to the correct url.

# After changing the url, don't forget to remove the above settings again. Move to your settings in the backend and check the url. Also, inside the options section, look for "permalinks". It will bring you to an options page where you can regenerate the dynamic links. Without this regenerating, links for assets, media files and so an would possibly keep pointing to the old url. 

Mon Feb 20 2023 06:20:42 GMT+0000 (Coordinated Universal Time)

#ios #swift #check #internet #network #connection #connect

Mon Feb 20 2023 06:19:26 GMT+0000 (Coordinated Universal Time)

#ios #swift #check #internet #connection #connect #network

Mon Jun 21 2021 10:21:52 GMT+0000 (Coordinated Universal Time)

#ssh #server #authentification #network

Fri Jun 11 2021 14:15:50 GMT+0000 (Coordinated Universal Time),

#wordpress #configuration #url #network

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension