Mouse and Keyboard sharing across Computers

We use multiple computers in workspace or in home. Often need to share same mouse and keyboard for all because you probably have a wireless/wired keyboard mouse set. here arises the issue that how to share same set of input controllers for both machines.

Below are a few free and paid options for you to choose from. They all work as expected when computers are connected via LAN or WiFi

  1. Mouse without Borders
  2. Barrier
  3. ShareMouse
  4. Synergy

Microsoft Garage Mouse without Borders

This is all time classic program to share clipboard, mouse movements and what not. For windows to windows mouse sharing this is the best.

It is FREE too

Barrier

This is best alternative in FREE category. It supports MAC OS and Windows both. so this is the one you should go with if you dont have just windows machines.

Sharemouse

This is a good one for cross OSs. It supports both windows and apple mac. Free version is okayish. Can get a bit buggy if you are using a HDMI switch for same monitor mirroring. But still gets the job done.

If you got some bucks to spare, use the paid version which has more features

Synergy

Synergy is the best paid software for this purpose. HANDS DOWN

Supports MAC, Windows and Linux just like the others but provides you support (because you have paid)

How to fix Undefined class constant ‘ARRAY_AS_PROPS’ Fatal Error?

I received this error “Fatal Error: Uncaught error in Undefined class constant ‘ARRAY_AS_PROPS'”
This issue is not related to PHP if you have 7.0 and above, it is zend framework’s module zend-http wrapper which is affected if Apache module is not present

File responsible: zendframework\zend-http\src\Header\Cookie.php:75

public function __construct(array $array = [])
{
        parent::__construct($array, ArrayObject::ARRAY_AS_PROPS);
}

Solution

Do check enabled modules for Apache, I found out that mod_expires was not enabled. So I edited httpd.conf and enabled mod_expires

I also enabled Zend Opcache in php.ini to make it run smooth on multiple pageloads.

Quick tips on American SALES TAX for developers who are setting up an ecommerce store for USA based organization

So, all of the info you read below is the summary of 6 hours I spent yesterday in gathering information about taxes in USA. – to be particular – Sales Tax. Not Income tax

To start with, USA has 50 states, meaning constituent political entity. All states have their own rules for sales tax and there is no nation-wide sales tax as such. So if you are an store owner in any particular, you will have to charge your customers taxes, which you are supposed to pay to the state.

Now when I say “charge your customers taxes”, I mean- obviously that is why you are here. There are two types of taxes based on the final location of the product after the purchase.

So there are origin based taxes and destination based taxes. Some states require you to charge customer depending upon your (seller’s) location. Summary- If you are located in an origin-based state and make sales to customers within that state, you would charge sales tax based on your location, including any local and state taxes.  Example – Illinois

Destination Based tax – If you are in state A and you make a sale to a customer living in state B, you have an obligation to collect and pay sales tax of state B, ONLY if you have a Nexus in state B

Now you must be wondering Nexus, what is a nexus in tax terms? So a nexus is kind of a link of your business to/in a certain state. Lets say your business is Registered and has a brick mortar office in state X, and you sell a lot to customers in state Y. Depending upon the volume and nature of transactions, State government requires you to register a Nexus in state Y so that you can collect sales tax for State Y- as simple as that. However, terms and legislation criteria on whether you should register a Nexus vary a lot from state to state. But it usually comes in scope when you are selling 250,000+ USD in a state which is not your home state.

Home state means where you run business.

Summary: You only charge sales tax if your customer’s shipping address is in your home state i.e., where your store is. Customers out of your state dont need to pay any taxes which purchasing from you.

Now coming to tax rates:

Tax rates are honestly very confusing when talking about USA. They have unreal system of managing tax rates and enduring tax-evasion problem.

Usually states have same taxes or even some countries have a fixed tax depending upon the product hierarchy, but that is not the case with USA.

There are chances that two addresses in same pincode will have different tax rates, YES! I am NOT kidding!

As per jurisdictions, the tax rates are combined. There is a State Tax Rate, County Tax Rate and City Tax Rate and maybe others too.

Combining all these give you an estimated tax rate which can be categorized per Pincode or ZIPcode but wont be 100% accurate. An Example is here – ZIP Codes: The wrong tool for the job However the article seems like an exaggeration because they want to sell their product/service of course.

Bottom Line- It can get really messy when dealing with Sales Tax in USA. Since I am not the tax guy and have no relation with accountancy whatsoever, there are chances that many of the things I stated above might be wrong. However, I believe that what I read online and the information that I gathered was from trust-able sources. The e-commerce store setup that I did was based on Magento 2, so I managed to create tax rates for each state. Later on, I found out I only needed to create tax rates for only one state i.e., our home state.

Here is a full list of all states combined: USA-allpincodes-mar2019.csv

And you can use following tax rates area wise- in Magento2 format

AlabamaIndianaNebraskaRhode Island
AlaskaIowaNevadaSouth Carolina
ArizonaKansasNew HampshireSouth Dakota
ArkansasKentuckyNew JerseyTennessee
CaliforniaLouisianaNew MexicoTexas
ColoradoMaineNew YorkUtah
ConnecticutMarylandNorth CarolinaVermont
DelawareMassachusettsNorth DakotaVirginia
FloridaMichiganOhioWashington
GeorgiaMinnesotaOklahomaWashington, DC
HawaiiMississippiOregonWest Virginia
IdahoMissouriPennsylvaniaWisconsin
IllinoisMontanaPuerto RicoWyoming

Reference for CSVs: https://www.avalara.com/taxrates/en/download-tax-tables.html

Reference for other details:
1. https://www.avalara.com/us/en/learn/whitepapers/origin-vs-destination-sales-tax.html
2. https://blog.taxjar.com/states-where-amazon-com-collects-sales-tax/
3. https://en.wikipedia.org/wiki/Sales_taxes_in_the_United_States
4. https://quickbooks.intuit.com/r/taxes/what-is-nexus-and-how-does-it-affect-your-small-business/

How to transpose an array in PHP with irregular subarray size?

    function transposeCsvData($data)
    {
	    $ct=0;
	    foreach($data as $key => $val)
        {
	        //echo count($val);
		    if($ct< count($val))
                $ct=count($val);
		    }
		//echo $ct;
	    $blank=array_fill(0,$ct,array_fill(0,count($data),null));
	    //print_r($blank);
	
	    $retData = array();
        foreach ($data as $row => $columns)
        {
            foreach ($columns as $row2 => $column2) 
            {
                $retData[$row2][$row] = $column2;
                }
            }
	    $final=array();
	    foreach($retData as $k=>$aval)
	    { 
            $final[]=array_replace($blank[$k], $aval);
           }
        return $final;
        }

Test Code

$a[]=array("name","john","sam","patrick");
$a[]=array("color","orange","green");
$a[]=array("bikes","suzuki","audi","mercedes","bmw","volks","rover");
$a[]=array("techgiants","samsung","amazon");

print_r(transposeCsvData($a));

Output

Array
(
    [0] => Array
        (
            [0] => name
            [1] => color
            [2] => bikes
            [3] => techgiants
        )

    [1] => Array
        (
            [0] => john
            [1] => orange
            [2] => suzuki
            [3] => samsung
        )

    [2] => Array
        (
            [0] => sam
            [1] => green
            [2] => audi
            [3] => amazon
        )

    [3] => Array
        (
            [0] => patrick
            [1] => 
            [2] => mercedes
            [3] => 
        )

    [4] => Array
        (
            [0] => 
            [1] => 
            [2] => bmw
            [3] => 
        )

    [5] => Array
        (
            [0] => 
            [1] => 
            [2] => volks
            [3] => 
        )

    [6] => Array
        (
            [0] => 
            [1] => 
            [2] => rover
            [3] => 
        )

)

SQL Notes

CREATE TABLE `clients` (
  `id` int(4) NOT NULL AUTO_INCREMENT,
  `name` varchar(11) NOT NULL,
  `associate` varchar(100) NOT NULL,
  `revenue` int(12) NOT NULL,
  `profit` int(12) NOT NULL,
   PRIMARY KEY (`id`),
   FOREIGN key (`associate`) references `emp`(`emp_code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

alter table `emp` add COLUMN `phone` int(12) not null after `name`
alter table `emp` add COLUMN `phone` int(12) null after `name`
alter table `emp` modify `phone` int(12) null
alter table `emp` drop column `phone`


ALTER TABLE `emp`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `emp_code` (`emp_code`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `emp`
--
ALTER TABLE `emp`
  MODIFY `id` int(4) NOT NULL AUTO_INCREMENT;
COMMIT;

How to fix Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI error in SSH?

Put this in your bash profile and run source ~/.bashrc

alias composer="/opt/cpanel/ea-php71/root/usr/bin/php /opt/cpanel/composer/bin/composer"

As Composer is now available via WHM you can use this to find it:

which composer

This returned path “/opt/cpanel/composer/bin/composer” for me. If this returns nothing then disregard the rest of this answer, as Composer is not available to you at system level.

You can now use php-cli to call this with Composer’s absolute path:

php-cli /opt/cpanel/composer/bin/composer install
php-cli /opt/cpanel/composer/bin/composer update
php-cli /opt/cpanel/composer/bin/composer require whatever/example

You may however need to alias php-cli if your system claims this isn’t found. It very much depends how PHP has been deployed on the WHM server. Learn how to fix PHP CLI error. You can do this by adding a user alias to the end of your “.bashrc” or “.bash_profile” file as follows:

alias php-cli=/opt/cpanel/ea-php72/root/usr/bin/php

Replace ea-php72 with the release of PHP you want to use. Submit this as a command in the shell to make it available immediately, otherwise it’ll become available when you open your next Bash session.

If you want to make this available with just composer alone you could create this alias again in “.bashrc”:

alias composer=/opt/cpanel/ea-php72/root/usr/bin/php /opt/cpanel/composer/bin/composer

Reference: https://stackoverflow.com/a/53478183/2229148

How to switch your DNS to Google DNS or Cloudflare DNS on Windows 10?

So, this is the scenario. You are using some local ISP which has its own DNS server fulfilling your DNS requests but to speed things up and not rely upon a DNS server which is updated less frequently. For that purpose,we can switch our computer’s DNS to some other public DNS like Google’s or Cloudflare DNS.

Step 1: Right click the Network Icon in your task bar.

Network Icon in Taskbar
Right Click the network icon in taskbar

Step 2: Choose “Open Network & Sharing Settings

Click Open Network & Sharing Settings
Click Open Network & Sharing Settings

Step 3: Click on “Change Adapter Options

change adapter options
change adapter options

Step 4: Right click on the active hardware and select “properties

adapter properties
adapter properties

Step 5: Select “Internet Protocol Version 4 (TCP/IPv4)” and Click Properties button in the bottom

IPv4 Properties

Step 6: Input the IP addresses after choosing “Use the following DNS Server Addresses

put dns ip here
put dns ip here

Step 7: Select OK to close the pop up window. Restart your browser and have a better browsing experience.


Cloudflare’s Public DNS Servers/addresses for IPv4:

1.1.1.1
1.0.0.1

Cloudflare’s Public DNS Servers/addresses for IPv6:

2606:4700:4700::1111
2606:4700:4700::1001

Google’s DNS Servers for IPv4:

8.8.8.8
8.8.4.4

The Google Public DNS IPv6 addresses are:

2001:4860:4860::8888
2001:4860:4860::8844

What happened to googleforwork.com? Welcome the new cloudconnect.goog domain

So GoogleforWork.com is now being redirected to cloud.google.com and the same applies for its subdomain connect.googleforwork.com.

Earlier the campaigns at google work communities are now hosted at www.cloudconnect.goog

It is interesting to note that it uses .goog and not .google TLD, here is some more info about .goog TLD

In the past we have seen .google tld for many purposes like AI to Everyone at ai.google     and Google’s design lab and research on design technology

The future will be interesting in terms of TLDs when banks, tech giants and telecom companies are switching their websites to their own custom TLDs and regular people can hardly remember the apparently new gTLDs.