Translate

Saturday, 31 August 2019

How to add PHP to a WordPress Page or Post?

WordPress comes with an intuitive visual editor that covers all your basic needs for posting content. No coding is needed. However, when making custom pages or posts, you might need to add your own PHP code.

How to add PHP to a WordPress page or post properly? Read on, I’ll present the easiest way to do that just below.

What is PHP?

PHP is a recursive-acronym that stands for PHP: Hypertext Preprocessor, a server-side scripting language used for web development.

As a scripting language, PHP is used to handle routine tasks, which means using the same code for repetitive tasks, like displaying today’s time on a website, for example.

Being a server-side language, it requires a PHP module installed on the server for processing PHP scripts. The script can be embedded into an HTML file, and once interpreted, will be displayed in the browser.

Here’s a very basic example of a PHP script:

<?php
echo 'Hi, Guys!';
?>

And here’s the output as seen on a web browser:

Hi, Guys

Before moving on to the how’s, it is important to ensure your WordPress knowledge is up to snuff. Adding PHP code to WordPress requires you to have at least basic knowledge of how WordPress works. There are many websites like HostingWiki that can widen your horizons about WordPress and everything related to web development.

How to Add PHP to WordPress?

Now, let’s learn how to add PHP to WordPress in two different scenarios: using a plugin and modifying the functions.php file. I’ll start with the easiest one.

Using a Plugin

To add the code, using a plugin to your WordPress site can be a hassle-free option.

Here are the steps that you need to do:

  • Login to your WordPress dashboard.
  • Go to the plugin menu and click Add New.

How to Add PHP to WordPress 1

  • Choose your favorite plugin. I recommend Insert PHP Code Snippet among others — It is easy to use and works well both on classic and Gutenberg editors.

How to Add PHP to WordPress 2

  • Install, and activate the plugin.
  • Once done, let’s move on to the insertion step.

Here are the steps to add the PHP code into WordPress once you have the plugin:

Creating the PHP code Snippet

  • First off, you need to create the code snippet. On your WordPress dashboard go to XYZ PHP code, and click PHPcode Snippets.

How to Add PHP to WordPress 3

  • On the PHPcode Snippet page, choose Add New PHP Code Snippet.

How to Add PHP to WordPress 4

  • Add the PHP code in the blank field as well as the Tracking name, then click Create.

How to Add PHP to WordPress 5

I use this code as an example:

<?php
echo 'Local date and time is: ';
date_default_timezone_set("America/New York");
echo date('d-m-Y h:i:s A');
?>
  • Once created, you’ll see the snippet shortcode.

How to Add PHP to WordPress 6

Adding the Snippet Short Code to a WordPress Post

The next thing is to insert the shortcode on your post. Here, I would like to show you how to do it using the Gutenberg editor.

  • From the WordPress dashboard, under the Posts menu, click Add New.
  • Click the plus In the Widgets drop-down menu, choose Shortcode.

How to Add PHP to WordPress 7

  • Copy/paste the snippet shortcode you created using the plugin.

How to Add PHP to WordPress 8

  • And here is the post published:

How to Add PHP to WordPress 9

Adding PHP to a WordPress Page

Adding PHP to a page is very similar to adding PHP to a post, nonetheless, there are a few differences as I will be using the classic editor this time around.

  • From the WordPress dashboard go to the Pages menu, click Add New.
  • From the formatting toolbar, you’ll see the PHP icon. Click that icon and choose the snippet code you want to use. No need to copy and paste here. From the options, I chose Local Time which is the snippet I’ve created earlier.

How to Add PHP to WordPress 10

  • The result when your page is published:

How to Add PHP to WordPress 10

Add PHP to WordPress Manually Using the functions.php File

You can also add the PHP code directly to your WordPress theme. For that purpose, you need to modify the functions.php file of the current theme you’re using. Backup your data first, before doing anything else, just in case something goes wrong!

Also, I recommend you to create a child theme, a sub-theme that has the same code and appearance but it can be used as a “dummy” in case any issues occur.

Here are the steps:

  • From the WordPress dashboard, go to the Appearance menu, and choose the Theme Editor.
  • On the right side, you’ll see Theme Files. Choose Theme Function or functions.php.

How to Add PHP to WordPress 11

  • Add or modify the PHP code for your content
  • Once finished, click Update File.

Using this method will change all your posts under the same theme. That means for individual changes, using a plugin should be the preferred option. Also, when you update your theme, you might lose your modifications.

Wrap Up

Adding PHP to a WordPress page or post should not be taken lightly. Otherwise, you might make a mistake that will break your site (always use backups!).

There are two methods to insert PHP code in WordPress: using a plugin and manually adding it into the functions.php file.

The first option is ideal for individual posts or pages while doing it manually can apply your code throughout your entire WordPress theme.

Remember to always make a backup for your WordPress site before modifying it, and good luck coding!

The post How to add PHP to a WordPress Page or Post? appeared first on The Crazy Programmer.



Friday, 30 August 2019

Foxit PDF Software Company Suffers Data Breach—Asks Users to Reset Password

If you have an online account with Foxit Software, you need to reset your account password immediately—as an unknown attacker has compromised your personal data and log-in credentials. Foxit Software, a company known for its popular lightweight Foxit PDF Reader and PhantomPDF applications being used by over 525 million users, today announced a data breach exposing the personal information of

Old Android App CamScanner With 100M Downloads Starts Delivering Malware

An old Android app stealthily targeted a Millions of Android users. As discovered by the researchers, CamScanner, an app that

Old Android App CamScanner With 100M Downloads Starts Delivering Malware on Latest Hacking News.



VM Escape Vulnerability Discovered In QEMU (Quick Emulator) Which Allowed For Code Execution

Reportedly, a VM escape vulnerability exists in QEMU – an open source hardware virtualization emulator. The flaw, upon exploit, could

VM Escape Vulnerability Discovered In QEMU (Quick Emulator) Which Allowed For Code Execution on Latest Hacking News.



An Overview of the Jooble Platform

Jooble is a job search engine created for a...

[[ This is a content summary only. Visit my website for full links, other content, and more! ]]

Ransomware Hits Dental Data Backup Service Offering Ransomware Protection

THIS WEEK IN THE IRONIC NEWS: DDS Safe, an online cloud-based data backup system that hundreds of dental practice offices across the United States are using to safeguard medical records and other information of their patients from ransomware attacks has been hit with ransomware. Provided by two Wisconsin-based companies, Digital Dental Record and PerCSoft, the backend system of affected

Google Uncovers How Just Visiting Some Sites Were Secretly Hacking iPhones For Years

Beware Apple users! Your iPhone can be hacked just by visiting an innocent-looking website, confirms a terrifying report Google researchers released earlier today. The story goes back to a widespread iPhone hacking campaign that cybersecurity researchers from Google's Project Zero discovered earlier this year in the wild, involving at least five unique iPhone exploit chains capable of

Thursday, 29 August 2019

Python Global Variables

In this tutorial we will be discussing about Python global variables.

A variable which is declared outside of any function i.e. in the global space is known as global variable.

Global variables are useful when multiple functions need to use the same data. In C, C++ we can use and modify global variables directly in local functions and if we declare a local variable with the same name of global variable then it shadows the global variable but this is not the case in Python.

Let’s see this with the help of one example :

def foo():
    print(x)
    
x = 5
foo()
print(x)

The output of the above program is:

5
5

Here x is global variable and it can be accessed in function and the program works correctly but what if we try to change the variable value inside the function.

def foo():
    x = x+2
    print(x)
    
x = 5
foo()
print(x)

When we run the above code, we will get the below error:

UnboundLocalError: local variable ‘x’ referenced before assignment

Here the problem is x in the function is now being treated as a local variable.

In python if it is just reading the variable and the variable doesn’t exist locally then it will try to look into any containing scope (Global scope in our first example). But this is not the case when we are trying to change the variable value. Python assumes that any variable whose value is being changed in any function is local to the function unless explicitly told.

To understand the above statement clearly let’s see one more example :

def foo():
    x = 2   
    print(x)
    
x = 5
print(x)
foo()
print(x)

The output of the above code is:

5
2
5

If you are familiar with C or C++ you may expect:

5
2
2

As your output but in Python the x declared inside the function is treated as local variable and has no relation with the x declared outside the function.

To use the x as global variable in foo we should use global keyword, x inside the function will then be treated as a global variable.

Here is an example:

def foo():
    global x
    x = 2   
    print(x)
    
x = 5
print(x)
foo()
print(x)

The output here is:

5
2
2

Using the global keyword we can make the function use the global copy of x and therefore any changes made to the function are reflected globally in x.

Why global keyword?

The global keyword is used because global variables are dangerous and are difficult to handle. Python wants to make sure that you really want to use global variable inside the function and therefore the global keyword is being used.

Let’s take an example to cover all the above points.

def hoo():
    print(x)

def boo():
    x = 6
    print(x)
    

def foo():
    global x
    x = 7
    print(x)
    
x = 5
hoo()  # print 5 
boo()  # print 6
hoo()  # print 5
foo()  # print 7
print(x) # print 7
hoo()  # print 7
boo()  # print 6

The output of the above program is:

5
6
5
7
7
7
6

Lets try to understand above code.

  • First call to hoo prints the global variable as it is just reading the variable x.
  • Calling boo will create a local copy of x inside the function and initialize it with 6 and therefore it will print 6. After the call to function is finished the local variable is discarded. This function will not affect global x.
  • As x is unaffected calling hoo again will print the global value of x i.e. 5
  • foo is using the global keyword and therefore it will now use the global copy of x and change made will directly change global x.
  • After the call to foo is executed value of global x is changed to 7 so print(x) will print 7.
  • hoo again will simply print the global value of x i.e. 7
  • Call to boo will create a local variable x with value 6 and will print it and global x will remain unchanged.

I hope now you got the idea about python global variables. Comment down below if you still have any queries.

The post Python Global Variables appeared first on The Crazy Programmer.



Google Will Now Pay Anyone Who Reports Apps Abusing Users' Data

In the wake of data abuse scandals and several instances of malware app being discovered on the Play Store, Google today expanded its bug bounty program to beef up the security of Android apps and Chrome extensions distributed through its platform. The expansion in Google's vulnerability reward program majorly includes two main announcements. First, a new program, dubbed 'Developer Data

How to Redesign Unsplash Using Styled Components

Redesigning Unsplash Using Styled Components

Writing future-proof CSS is hard. Conflicting classnames, specificity issues, and so on, come up when you have to write and maintain thousands of lines of CSS. To get rid of the aforementioned issues, Styled Components was created.

Styled Components makes it easy to write your CSS in JS and makes sure there are no conflicting classnames or specificity issues with multiple other benefits. This makes writing CSS a joy.

In this tutorial, we’ll explore what CSS in JS is, the pros and cons of styled-components, and finally, we’ll redesign Unsplash using Styled Components. After completing this tutorial, you should be able to quickly get up and running with Styled Components.

Note: Styled Components was specifically built with React in mind, so you have to be using React to use Styled Components.

Prerequisites

For this tutorial, you need a basic knowledge of React.

Throughout the course of this tutorial we’ll be using yarn. If you don’t have yarn already installed, then install it from here.

To make sure we’re on the same page, these are the versions used in this tutorial:

  • Node 12.6.0
  • npx 6.4.1
  • yarn 1.17.3

Evolution of CSS

Before CSS-in-JS was created, the most common way to style web apps was to write CSS in a separate file and link it from the HTML.

But this caused trouble in big teams. Everyone has their own way of writing CSS. This caused specificity issues and led to everyone using !important.

Then came Sass. Sass is an extension of CSS that allows us to use things like variables, nested rules, inline imports and more. It also helps to keep things organized and allows us to create stylesheets faster.

Even though Sass might be thought of as an improvement over CSS, it arguably causes more harm than good without certain systems put in place.

Later, BEM came in. BEM is a methodology that lets us reduce specificity issues by making us write unique classnames. BEM does solve the specificity problem, but it makes the HTML more verbose. Classnames can become unnecessarily long, and it's hard to come up with unique classnames when you have a huge web app.

After that, CSS Modules were born. CSS Modules solved what neither Sass nor BEM could — the problem of unique classnames — by tooling rather than relying on the name given by a developer, which in turn solved specificity issues. CSS Modules gained a huge popularity in the React ecosystem, paving the way for projects like glamor.

The only problem with all these new solutions was that developers were made to learn new syntaxes. What if we could write CSS exactly how we write it in a .css file but in JS? And thus styled-components came into existence.

Styled Components uses Template Literals, an ES6 feature. Template literals are string literals allowing embedded expressions. They allow for multi-line strings and string interpolation features with them.

The main selling point of Styled Components is that it allows us to write exact CSS in JS.

Styled Components has a lot of benefits. Some of the pros and cons of Styled Components are listed below.

Pros

There are lots of advantages to using Styled Components.

  1. Injecting Critical CSS into the DOM

    Styled Components only injects critical CSS on the page. This means users only download CSS needed for that particular page and nothing else. This loads the web page faster.

  2. Smaller CSS bundle per page

    As it only injects styles that are used in the components on the page, bundle size is considerably smaller. You only load the CSS you need, instead of excessive stylesheets, normalizers, responsiveness, etc.

  3. Automatic Vendor Prefixing

    Styled Components allows you to write your CSS and it automatically vendor prefixes according to the latest standard.

  4. Remove unused CSS

    With Styled Components, it's easier to remove unused CSS or dead code, as the styles are colocated with the component. This also impacts on reducing bundle size.

  5. Theming is easy

    Styled Components makes it really easy to theme a React applications. You can even have multiple themes in your applications and yet easily maintain them.

  6. Reduces the number of HTTP requests

    Since there are no CSS files for resets, normalizers, and responsiveness, the number of HTTP requests are considerably reduced.

  7. Unique Classnames

    Styled Components generates unique classnames every time a build step takes place. This allows avoiding naming collisions or specificity issues. No more having global conflicts and being forced to resolve them with !important tags.

  8. Maintenance is easy

    Styled Components allows you to colocate styles with the component. This allows for painless maintenance. You know exactly which style is affecting your component, unlike in a big CSS file.

Cons

Of course, nothing's perfect. Let's look at some downsides associated with Styled Components.

  1. Unable to Cache Stylesheets

    Generally, a web browser caches .css files when a user visits a website for the next visit, so it doesn't have to download the same .css file again. But with styled-components, the styles are loaded in the DOM using the <style> tag. Thus, they can’t be cached and every time user has to request styles when they visit your website.

  2. React specific

    Styled Components was made with React in mind. Thus, it’s React specific. If you use any other framework, then you can’t use Styled Components.

    However, there’s an alternative very similar to styled-components known as emotion which is framework agnostic.

The post How to Redesign Unsplash Using Styled Components appeared first on SitePoint.



Capital One Hacker Also Accused of Hacking 30 More Companies and CryptoJacking

Former Amazon employee Paige Thompson, who was arrested last month in relation to the Capital One data breach, has been accused of hacking not only the U.S. credit card issuer, but also more than 30 other companies. An indictment unsealed on Wednesday revealed that Thompson not just stole data from misconfigured servers hosted with a cloud-computing company, but also used the computing power

A Privilege Escalation Vulnerability Discovered In Check Point’s Endpoint Security

A serious vulnerability was discovered in the Check Point Software that could allow an attacker elevate privileges and execute arbitrary

A Privilege Escalation Vulnerability Discovered In Check Point’s Endpoint Security on Latest Hacking News.



Apple Changes the Way It Listens to Your Siri Recordings Following Privacy Concerns

Apple today announced some major changes to its controversial 'Siri audio grading program' following criticism for employing humans to listen to audio recordings of users collected via its voice-controlled Siri personal assistant without their knowledge or consent. The move came a month after The Guardian reported that third-party contractors were regularly listening to private conversations

Wednesday, 28 August 2019

Imperva Disclosed Security Breach That Affected Cloud WAF Customers

Whilst you would expect cybersecurity and IT firms to serve customers with adequate online security measures. However, these firms themselves

Imperva Disclosed Security Breach That Affected Cloud WAF Customers on Latest Hacking News.



Apple Released iOS 12.4.1 and Fixed An iPhone Jailbreak Vulnerability

Last week, a researcher discovered a jailbreaking vulnerability in iOS 12.4 that Apple accidentally unpatched. The vulnerability allowed jailbreaking many

Apple Released iOS 12.4.1 and Fixed An iPhone Jailbreak Vulnerability on Latest Hacking News.



Magecart Hackers Compromise 80 More eCommerce Sites to Steal Credit Cards

Cybersecurity researchers have discovered over 80 Magecart compromised e-commerce websites that were actively sending credit card information of online shoppers to the attackers-controlled servers. Operating their businesses in the United States, Canada, Europe, Latin America, and Asia, many of these compromised websites are reputable brands in the motorsports industry and high fashion,

Cross-Site Scripting (XSS): Web App Enemy Number One

Web applications are both a valuable resource for organizations and one of the biggest threats to their cyber security. Web apps are designed to be exposed to users via the Internet, allowing them the convenience of interacting with their accounts via their browser. However, this same easy access also makes these web apps a prime target for attackers trying to breach the organization’s defenses.

When attempting to secure a web application (or any software), it is extremely useful to know what to look for. The wide variety of potential attacks against web applications makes it easy to overlook a certain vulnerability class when performing a search for vulnerabilities.

An extremely valuable resource for this is the OWASP Top 10 list, which lists the ten most common vulnerabilities based off of the analysis of the Open Web Application Security Project (OWASP). This list is updated every few years and is based upon a combination of data and the opinions of experts in the field.

However, there are also other useful sources of data regarding the vulnerability threat landscape in the real world. Penetration testers see the vulnerabilities that exist in the wild, so they’re worth listening to when they provide information regarding the threats that they are seeing most often.

Vulnerabilities in the Real World

When trying to figure out what the most common and important vulnerabilities are present in real-world software, it’s useful to go to the source. Penetration testers are the cybersecurity experts commonly tasked with testing an organization’s cyber defenses and reporting on the vulnerabilities that they find.

In the past, it has been difficult to acquire large-scale cyber vulnerability data since the results of assessments are typically kept confidential and few companies have the scale necessary to discover general trends. However, the rise of crowd-sourced vulnerability detection organizations, like HackerOne, have changed this.

Unlike traditional penetration testing companies, which have a team of pen testers on staff to perform assessments, HackerOne acts as a middleman between companies and groups of freelance testers. Access to the test environment is provided through HackerOne, allowing them to collect statistical data about the assessments performed and the types of vulnerabilities discovered.

According to the company, currently the most common type of vulnerability on web applications is cross-site scripting (XSS). This may come as a surprise since most attacks that make the headlines don’t involve XSS. This is because the headlines are usually focused on data breaches, and XSS vulnerabilities rarely lead to large-scale data breaches. However, $8 million of the $55 million paid out in bug bounties on HackerOne went to discoveries of XSS vulnerabilities in companies’ web applications. This underscores how common these vulnerabilities are since they carry lower rewards per detection that other “more damaging” vulnerabilities.

What is Cross-Site Scripting (XSS)

Cross-Site Scripting (XSS)

Image Source

The Internet use many different methods to control access to sensitive of protected resources. One of these mechanisms is the same-origin policy. According to the same-origin policy, if content from a site is granted access to a protected resource, other content coming from the same place (same URI, domain, and port number) can take advantage of the same access without being granted specific permission. Cross-site scripting (XSS) attacks take advantage of this policy to gain unauthorized access to protected resources.

There are several different types of cross-site scripting, but they all involve injection of malicious code into a trusted website. This code injection is made possible by vulnerabilities in the web application itself, the web server where the code is hosted, or any plug-ins that the application uses.

When a user browses to an affected website, they receive both the legitimate code of the site as well as a malicious script injected by the attacker. Since all of this code comes from “the same place”, the single-origin policy means that the malicious code has access to the same data and resources as the legitimate website code. This gives the attacker access to any protected, sensitive data used by the legitimate page, which may be used to steal personal data (like credit card information) or data (like session cookies) that can allow the attacker to access the user’s account directly.

Protecting Your Web Apps

Cross-site scripting (XSS) and other web application vulnerabilities can be a severe threat to an organization’s network and data security. Web applications are designed to be publicly exposed on the Internet and act as a gatekeeper for protected data or functionality. If they are compromised by a hacker, they can act as a foothold for the attacker to expand their access onto the protected network and/or as a means of collecting sensitive user data.

Protecting against XSS vulnerabilities and other web application vulnerabilities listed on the OWASP Top Ten is one of the main features of a web application firewall (WAF). The attacks used to exploit these vulnerabilities are well-known and can be detected and prevented using a WAF.

However, the threat surface of a web application is not limited to the attacks included on OWASP’s Top Ten list. These other attack vectors are where the best WAFs stand out from the rest of the pack. Signature-based detection helps with known attacks, but a WAF also needs anomaly-based detection to identify and protect against unknown threats. Protecting a web application requires the ability to stop any attack, so choosing a strong WAF is a crucial aspect of any organization’s network security strategy.

The post Cross-Site Scripting (XSS): Web App Enemy Number One appeared first on The Crazy Programmer.



French Police Remotely Removed RETADUP Malware from 850,000 Infected PCs

The French law enforcement agency, National Gendarmerie, today announced the successful takedown of one of the largest wide-spread RETADUP botnet malware and how it remotely disinfected more than 850,000 computers worldwide with the help of researchers. Earlier this year, security researchers at Avast antivirus firm, who were actively monitoring the activities of RETADUP botnet, discovered a

Tuesday, 27 August 2019

Instagram Vulnerability Disclosed That Could Have Allowed For Hacking of Over 1 Million Users Accounts

Last month, a researcher elaborated how exploiting a flaw could allow hacking any Instagram account within 10 minutes. Once again,

Instagram Vulnerability Disclosed That Could Have Allowed For Hacking of Over 1 Million Users Accounts on Latest Hacking News.



Attackers Target Company Recruitment Processes With Phoney Job Applications Loaded With Quasar RAT

Here comes a problem for job seekers and recruiters. The attackers are now targeting organizations by impersonating job seeker applications.

Attackers Target Company Recruitment Processes With Phoney Job Applications Loaded With Quasar RAT on Latest Hacking News.



Hostinger Warns Security Breach Might Have Affected 14 Million Customers

Continuing the trail of data breaches now joins the web hosting company Hostinger. As revealed by the firm itself, Hostinger

Hostinger Warns Security Breach Might Have Affected 14 Million Customers on Latest Hacking News.



Imperva Breach Exposes WAF Customers' Data, Including SSL Certs, API Keys

Imperva, one of the leading cybersecurity startups that helps businesses protect critical data and applications from cyberattacks, has suffered a data breach that has exposed sensitive information for some of its customers, the company revealed today. The security breach particularly affects customers of Imperva's Cloud Web Application Firewall (WAF) product, formerly known as Incapsula, a

WARNING — Malware Found in CamScanner Android App With 100+ Million Users

Beware! Attackers can remotely hijack your Android device and steal data stored on it, if you are using CamScanner, a highly-popular Phone PDF creator app with more than 100 million downloads on Google Play Store. So, to be safe, just uninstall the CamScanner app from your Android device now, as Google has already removed the app from its official Play Store. Unfortunately, CamScanner has

Numerous WordPress Plugins Under Exploit To Direct Traffic To Malicious Websites

WordPress plugins have once again made it on the hitlist for cybercriminals. These attacks are clearly using plugins to execute

Numerous WordPress Plugins Under Exploit To Direct Traffic To Malicious Websites on Latest Hacking News.



Monday, 26 August 2019

Apple Releases iOS 12.4.1 Emergency Update to Patch 'Jailbreak' Flaw

Apple just patched an unpatched flaw that it patched previously but accidentally unpatched recently — did I confuse you? Let's try it again... Apple today finally released iOS 12.4.1 to fix a critical jailbreak vulnerability, like it or not, that was initially patched by the company in iOS 12.3 but was then accidentally got reintroduced in the previous iOS 12.4 update. For those unaware,

Fortnite Users Targeted With Syrk Ransomware With Guise Of A Hack Tool

Heads up Fortnite players! Here’s some ransomware coming your way! Disguised as a Fortnite hack tool, the Syrk ransomware is

Fortnite Users Targeted With Syrk Ransomware With Guise Of A Hack Tool on Latest Hacking News.



IRS Issues Alert For Phishing Scam Targeting Taxpayers

Phishing scams are not always aimed at stealing users’ credentials. Rather the attackers also phish users to deliver malware and

IRS Issues Alert For Phishing Scam Targeting Taxpayers on Latest Hacking News.



Google Chrome To Alert Users Of Breached Passwords Via Built-In Browser Feature

Frequent data breaches have made it a mess for users to set up unique login credentials for an account. However,

Google Chrome To Alert Users Of Breached Passwords Via Built-In Browser Feature on Latest Hacking News.



High-Severity Vulnerability Discovered In Pre-Installed Software on Lenovo Devices

Lenovo devices have a years-old security flaw that remained unpatched until recently. As revealed, the preinstalled Lenovo software ‘Lenovo Solutions

High-Severity Vulnerability Discovered In Pre-Installed Software on Lenovo Devices on Latest Hacking News.



4 Key Principles to Remember When Building B2B Ecommerce Websites

4 Key Principles to Remember When Building B2B Ecommerce Websites

This article was created in partnership with StudioWorks. Thank you for supporting the partners who make SitePoint possible.

B2B ecommerce businesses are currently facing a bit of a boom. Forrester estimates that B2B ecommerce revenues will reach $1.8 trillion in the US in the next four years. And a recent BigCommerce study found that 41% of B2B retailers predict their online sales to increase more than 25% by the end of the year.

So if you’re building a B2B ecommerce storefront to capitalize on this boom, it’s important that you take the time to ensure that the website has all the right functionality to receive and fulfill orders, and to deliver a great shopping experience to your buyers.

In this post, we’ll take a look at some of the key principles you’ll need to keep in mind when tackling a B2B ecommerce website build.

But before we begin, let’s put everything into a bit of context.

Key Differences Between B2C and B2B Ecommerce Sites

B2B ecommerce companies, of course, provide the goods and services that other companies need to operate and grow. In the ecommerce space, when we refer to a B2B company, we’re generally talking about firms that sell physical goods on a wholesale basis, but other types of B2B companies have been known to get into the ecommerce game.

For example, industrial suppliers or consultancy service providers are generally B2B companies, and they may or may not offer online purchasing options too. B2C companies, on the other hand, sell their products and services direct to individual customers.

Currently, the B2B ecommerce opportunity is huge compared to B2C ecommerce, which has become harder to crack due to high levels of competition and low barriers to entry. B2B buyers are becoming increasingly interested in making purchases online. Sellers, meanwhile, are only starting to make it possible.

But just because the demand is there doesn’t mean corporate buyers are expecting the same type of experiences from B2B ecommerce that they get on Amazon. Here are a few key differences between B2B and B2C, when it comes to ecommerce interfaces and customer experiences.

  • Breadth of audience

    One major difference between B2B and B2C is the scale of their target audience. B2B sites deal with buyers who have simple, targeted profiles such as CTOs at tech startups. On the flip side, B2C sites have a broader group of people to cater to — for instance, moms with toddlers or millennials who are into sneakers.

    For this reason, B2B ecommerce sites typically have a different purchasing user flow which involves more personalization.

  • Average price point

    Most B2C ecommerce sites sell to hundreds of thousands of customers because their products typically sell at a lower price point. On the other hand, B2B sites may have less than 100 customers.

    B2B ecommerce sites often use quote builders and set up different technology to be able to accept and process larger orders. For example, this may include options for recurring payments, bulk discounts, and shipping.

  • The decision-making process

    B2C buying decisions are made fairly quickly, as they’re generally less rational and more based on impulse. Lower pricing points make this possible. In B2B decisions, the purchasing manager may have to get approval from senior executives, finance, marketing, and legal departments before placing an order.

    To streamline the decision-making process, B2B ecommerce site owners offer tailored pricing to buyers. They also set up customer accounts to make it easy for buyers to fill out orders and complete transactions.

With the above in mind, let’s take a closer look at some of the important principles to guide you as you build your next B2B ecommerce website.

1. Integrate with an ERP Solution

As a B2B company, you’ll be able to significantly increase productivity by integrating an ERP solution with your ecommerce site.

The key benefit is that your inventory levels will automatically update in two places. Inventory availability figures can appear on the front end of the site as goods are added to inventory, giving customers a better shopping experience. Plus, with access to ERP data on the back end, you can enable your staff to easily meet orders and forecast product demand.

Another key benefit of integrating an ERP solution is that you won’t need to hire additional workers in case product demand goes up.

Here are some of the most common ERP integration patterns:

  • Migration. Data migration ERP refers to the movement of a particular set of data between two systems at a specific point in time. The migration can either be on an as-needed basis through an API or on command by setting the configuration parameters to pass into the API calls.
  • Broadcast. The broadcast ERP integration pattern involves the transfer of data from one source system to multiple destination systems in real time. Broadcast systems help move data quickly between systems and keep multiple systems up to date across time.
  • Aggregation. This ERP pattern receives data from multiple systems and stores it into only one system. It eliminates the need to regularly run multiple migrations, which removes the risk associated with data synchronization and accuracy.
  • Bi-directional synchronization. Bi-directional sync ERP integration is useful in situations where different systems are required to perform different functions in the same data set.
  • Correlation. Correlation is similar to bi-directional ERP integration. The difference is that the former synchronizes objects only if they’re present in both systems.

BigCommerce offers a number of ERP integrations, including Brightpearl, Stitch Labs, NetSuite ERP Connector by Patchworks, and Acumatica Cloud ERP by Kensium via the eBridge Connections systems integrator.

The post 4 Key Principles to Remember When Building B2B Ecommerce Websites appeared first on SitePoint.



GitHub Revamps 2FA With WebAuthn Support For Security Keys

GitHub has taken another step towards enhancing its security features. As announced recently, the popular developers’ platform GitHub is now

GitHub Revamps 2FA With WebAuthn Support For Security Keys on Latest Hacking News.



The Future Of iTunes For Windows: Bright or Not Much?

The news of global changes in iTunes started back...

[[ This is a content summary only. Visit my website for full links, other content, and more! ]]

Hostinger Suffers Data Breach – Resets Password For 14 Million Users

Popular web hosting provider Hostinger has been hit by a massive data breach, as a result of which the company has reset passwords for all customers as a precautionary measure. In a blog post published on Sunday, Hostinger revealed that "an unauthorized third party" breached one of its servers and gained access to "hashed passwords and other non-financial data" associated with its millions of

Binance Confirms Hacker Obtained Its Users' KYC Data from 3rd-Party Vendor

As suspected, the KYC details of thousands of Binance's customers that hackers obtained and leaked online earlier this month came from the company's third-party vendor, Malta-based cryptocurrency exchange Binance confirmed. For those unaware, Binance, the world's largest cryptocurrency exchange by volume, hit by a "Potential KYC leak" earlier this month, with an unknown hacker distributing

Angular vs AngularJS – Difference between Angular and AngularJS

In this article, you will learn about the difference between Angular and AngularJS.

Angular

It is a very well known top front-end framework. It uses Microsoft’s TypeScript language which has many advantages like type declarations, type checking, object-oriented features and the benefits of ES6 like iterators and lambdas.

It has many versions like 2, 4, 5, 6, 7, 8 and they all are completely different from AngularJS. Angular Versions above 4 are just improvements and are backwards compatible with Angular.

In this, we use round braces “( )” for event binding and square brackets “[ ]” for property binding. In this, we are also using structural derivatives to put conditions in the HTML template.

Angular gives a better structure to more easily create and maintain big applications and a better change detection mechanism.

Pros:

  • TypeScript (TS) improves the code quality and efficiency using the OOPS (Object-Oriented Programming System) concept.
  • It’s a mobile-oriented.
  • In this, it updated the dependency injection technique and improved modularity means you can make the program independent.
  • It gives more option for programming languages like TypeScript (TS), EcmaScript5 (ES5), and EcmaScript6 (ES6) for writing codes.
  • You can easily configure routing in different file or module.
  • Flexible when using filters

Cons:

  • It is a little complex to configure as compared to AngularJS.
  • It is incapable if you only want to build simple, static web apps.

AngularJS

It was created in 2009. This brings us the concept of two-way data binding. It is an open-source, JavaScript-based, best framework for web app development.

Pros:

  • It has model data binding which makes web application development real quick.
  • Practising HTML as a structural lang. makes things easier to do.
  • It’s a perfect solution for fast web development because it does not need any other frameworks (set of libraries).
  • AngularJS applications can execute on all important programs and advanced phones including iOS, Android.

Cons:

  • It is big and complex because of the various ways of doing the same thing.
  • If we want to scale our app then its implementation is not easy.
  • If the user of an AngularJS web app disables JS, then only the basic page is clear to the user.
  • There’s a slow response in loading UI if there are more than 200 viewers.

The thing i.e common in angular & angularJS is that both are bi-directional means the two-way binding is done in both.

We can compare both based on architecture, language, expression syntax, mobile support, and routing.

Angular vs AngularJS – Difference between Angular and AngularJS

Angular vs AngularJS - Difference between Angular and AngularJS

Image Source

          Angular              AngularJS
It is a framework. It is a library.
The architecture in this framework is entirely component-based means it’s composed of encapsulated, loosely bound components. The architecture in this library is based on the model-view-controller (MVC) design.
It’s easy to create native applications for the mobile platform using Angular 2.0. It does not support for native applications for the mobile platform.
It comes with a built-in dependency injection subsystem for better. There are issues with dependency injection in AngularJS.
Controllers and $scope are replaced by Controllers and Derivatives. Controllers and $scope are key components.
Build using typescript which is a superset of JS (ES6). Built using javascript.
Angular uses @RouteConfig{(…)} decorator. AngularJS uses $routeprovider.when() to configure routing.

Comment below if you have any queries related to difference between Angular and AngularJS.

The post Angular vs AngularJS – Difference between Angular and AngularJS appeared first on The Crazy Programmer.



Sunday, 25 August 2019

25+ JavaScript Shorthand Coding Techniques

Child between piles of books

This really is a must read for any JavaScript developer. I have written this guide to shorthand JavaScript coding techniques that I have picked up over the years. To help you understand what is going on, I have included the longhand versions to give some coding perspective.

August 26th, 2019: This article was updated to add new shorthand tips based on the latest specifications. If you want to learn more about ES6 and beyond, sign up for SitePoint Premium and check out our extensive library of modern JavaScript resources.

1. The Ternary Operator

This is a great code saver when you want to write an if..else statement in just one line.

Longhand:

const x = 20;
let answer;

if (x > 10) {
    answer = "greater than 10";
} else {
    answer =  "less than 10";
}

Shorthand:

const answer = x > 10 ? "greater than 10" : "less than 10";

You can also nest your if statement like this:

const answer = x > 10 ? "greater than 10" : x < 5 ? "less than 5" : "between 5 and 10";

2. Short-circuit Evaluation Shorthand

When assigning a variable value to another variable, you may want to ensure that the source variable is not null, undefined, or empty. You can either write a long if statement with multiple conditionals, or use a short-circuit evaluation.

Longhand:

if (variable1 !== null || variable1 !== undefined || variable1 !== '') {
     let variable2 = variable1;
}

Shorthand:

const variable2 = variable1  || 'new';

Don’t believe me? Test it yourself (paste the following code in es6console):

let variable1;
let variable2 = variable1  || 'bar';
console.log(variable2 === 'bar'); // prints true

variable1 = 'foo';
variable2 = variable1  || 'bar';
console.log(variable2); // prints foo

Do note that if you set variable1 to false or 0, the value bar will be assigned.

3. Declaring Variables Shorthand

It's good practice to declare your variable assignments at the beginning of your functions. This shorthand method can save you lots of time and space when declaring multiple variables at the same time.

Longhand:

let x;
let y;
let z = 3;

Shorthand:

let x, y, z=3;

4. If Presence Shorthand

This might be trivial, but worth a mention. When doing “if checks”, assignment operators can sometimes be omitted.

Longhand:

if (likeJavaScript === true)

Shorthand:

if (likeJavaScript)

Note: these two examples are not exactly equal, as the shorthand check will pass as long as likeJavaScript is a truthy value.

Here is another example. If a is NOT equal to true, then do something.

Longhand:

let a;
if ( a !== true ) {
// do something...
}

Shorthand:

let a;
if ( !a ) {
// do something...
}

5. JavaScript For Loop Shorthand

This little tip is really useful if you want plain JavaScript and don't want to rely on external libraries such as jQuery or lodash.

Longhand:

const fruits = ['mango', 'peach', 'banana'];
for (let i = 0; i < fruits.length; i++)

Shorthand:

for (let fruit of fruits)

If you just wanted to access the index, do:

for (let index in fruits)

This also works if you want to access keys in a literal object:

const obj = {continent: 'Africa', country: 'Kenya', city: 'Nairobi'}
for (let key in obj)
  console.log(key) // output: continent, country, city

Shorthand for Array.forEach:

function logArrayElements(element, index, array) {
  console.log("a[" + index + "] = " + element);
}
[2, 5, 9].forEach(logArrayElements);
// a[0] = 2
// a[1] = 5
// a[2] = 9

6. Short-circuit Evaluation

Instead of writing six lines of code to assign a default value if the intended parameter is null or undefined, we can simply use a short-circuit logical operator and accomplish the same thing with just one line of code.

Longhand:

let dbHost;
if (process.env.DB_HOST) {
  dbHost = process.env.DB_HOST;
} else {
  dbHost = 'localhost';
}

Shorthand:

const dbHost = process.env.DB_HOST || 'localhost';

7. Decimal Base Exponents

You may have seen this one around. It’s essentially a fancy way to write numbers without the trailing zeros. For example, 1e7 essentially means 1 followed by 7 zeros. It represents a decimal base (which JavaScript interprets as a float type) equal to 10,000,000.

Longhand:

for (let i = 0; i < 10000; i++) {}

Shorthand:

for (let i = 0; i < 1e7; i++) {}

// All the below will evaluate to true
1e0 === 1;
1e1 === 10;
1e2 === 100;
1e3 === 1000;
1e4 === 10000;
1e5 === 100000;

8. Object Property Shorthand

Defining object literals in JavaScript makes life much easier. ES6 provides an even easier way of assigning properties to objects. If the variable name is the same as the object key, you can take advantage of the shorthand notation.

The post 25+ JavaScript Shorthand Coding Techniques appeared first on SitePoint.



Serious Security Vulnerability Found In Bitdefender Antivirus Free 2020

Antivirus software supposedly provide robust security to users against cyber attacks. However, like all other tools, these tools can also

Serious Security Vulnerability Found In Bitdefender Antivirus Free 2020 on Latest Hacking News.



AhMyth Malware Appears on Google Play Store As a Music App

Researchers have spotted an artistic way adopted by hackers to spy on users. Reportedly, a music app existed on the

AhMyth Malware Appears on Google Play Store As a Music App on Latest Hacking News.



You Can Now Manage ‘Off-Facebook Activity’ And Control Info Sharing With Facebook

Facebook has taken one more step towards providing better (not the best though) privacy to their users. They have now

You Can Now Manage ‘Off-Facebook Activity’ And Control Info Sharing With Facebook on Latest Hacking News.



Valve Admit Their Mistakes After Banning Researcher On The HackerOne Bug Bounty Platform

Recently, a researcher publicly disclosed a zero-day vulnerability in Steam that affected millions of users. He had to publicly disclosed

Valve Admit Their Mistakes After Banning Researcher On The HackerOne Bug Bounty Platform on Latest Hacking News.



Instagram Phishing Campaign Tricks Users With Fake Account Login Alerts

Heads up Instagram users! Hackers are on their way to try and steal your login credentials. Reportedly, an Instagram phishing

Instagram Phishing Campaign Tricks Users With Fake Account Login Alerts on Latest Hacking News.



New Adwind Malware Campaign Targets Utilities Industry Via Phishing Techniques

The infamous Adwind malware is ready to take on the utilities sector this time. Researchers have discovered a phishing campaign

New Adwind Malware Campaign Targets Utilities Industry Via Phishing Techniques on Latest Hacking News.



Friday, 23 August 2019

Hacker Ordered to Pay Back Nearly £1 Million to Phishing Victims

A prolific hacker who carried out phishing scams against hundreds of companies worldwide has been ordered to pay back more than $1.1 million (over £922,000) worth of cryptocurrencies to his victims. Grant West, a 27-year-old resident of Kent, England, targeted several well-known companies around the world since 2015 to obtain the financial data of tens of thousands of customers and then sold

SitePoint Premium New Releases: Form Design + Cloning Tinder

We're working hard to keep you on the cutting edge of your field with SitePoint Premium. We've got plenty of new books to check out in the library — let us introduce you to them.

Form Design Patterns

On first glance, forms are simple to learn. But when we consider the journeys we need to design, the users we need to design for, the browsers and devices being used; and ensuring that the result is simple and inclusive, form design becomes a far more interesting and bigger challenge.

➤ Read Form Design Patterns.

Cloning Tinder Using React Native Elements and Expo

In this tutorial, we’ll be cloning the most famous dating app, Tinder. We’ll then learn about a UI framework called React Native Elements, which makes styling React Native apps easy. Since this is just going to be a layout tutorial, we’ll be using Expo, as it makes setting things up easy.

➤ Read Cloning Tinder Using React Native Elements and Expo.

And More to Come…

We're releasing new content on SitePoint Premium regularly, so we'll be back next week with the latest updates. And don't forget: if you haven't checked out our offering yet, take our library for a spin.

The post SitePoint Premium New Releases: Form Design + Cloning Tinder appeared first on SitePoint.



Week in security with Tony Anscombe

ESET research uncovers the first known instances of spyware that is based on the AhMyth Remote Access Tool and has snuck into Google Play

The post Week in security with Tony Anscombe appeared first on WeLiveSecurity



Cyberbullying: What schools and teachers can do

How schools and educators can address and help prevent abusive behavior on the internet

The post Cyberbullying: What schools and teachers can do appeared first on WeLiveSecurity



Google Proposes 'Privacy Sandbox' to Develop Privacy-Focused Ads

Google today announced a new initiative—called Privacy Sandbox—in an attempt to develop a set of open standards that fundamentally enhances privacy on the web while continuing to support a free, open and democratic Internet through digital advertisements. A lot of websites on the Internet today, including The Hacker News, rely on online advertisements as their primary source of funding to

Thursday, 22 August 2019

A Malware Showcase | Understanding Malware With Python

Malware showcase is a Github repository that contains examples of malware usage and behavior, this repo should be used only

A Malware Showcase | Understanding Malware With Python on Latest Hacking News.



How to Use Windows Subsystem for Linux 2 and Windows Terminal

Using Windows Subsystem for Linux 2 and Windows Terminal

In this article, you’ll learn how you can set up and run a local Linux shell interface in Windows without using a virtual machine. This not like using terminals such as Git Bash or cmder that have a subset of UNIX tools added to $PATH. This is actually like running a full Linux kernel on Windows that can execute native Linux applications. That's pretty awesome, isn't it?

If you’re an experienced developer, you already know that Linux is the best platform on which to build and run server-based solutions using open-source technologies. While it’s possible to run the same on Windows, the experience is not as great. The majority of cloud hosting companies offer Linux to clients to run their server solutions in a stable environment. To ensure software works flawlessly on the server machine just like on the local development machine, you need to run identical platforms. Otherwise, you may run into configuration issues.

When working with open-source technologies to build a project, you may encounter a dependency that runs great on Linux but isn’t fully supported on Windows. As a result, Windows will be required to perform one of the following tasks in order to contribute to the project:

  • Dual Boot Windows and Linux (switch to Linux to contribute code)
  • Run a Linux virtual machine using a platform such as Vagrant, VirtualBox, VMWare etc.
  • Run the project application inside a Docker container

All the above solutions require several minutes from launch to have a full Linux interface running. With the new Windows Subsystem for Linux version 2 (WSL2), it takes a second or less to access the full Linux shell. This means you can now work on Linux-based projects inside Windows with speed. Let's look into how we can set up one in a local machine.

Installing Ubuntu in Windows

First, you'll need to be running the latest version of Windows. In my case, it's build 1903. Once you've confirmed this, you'll need to activate the Windows Subsystem for Linux feature. Simply go to Control-Panel -> Programs -> Turn Windows feature on or off. Look for "Windows Subsystem for Linux" and mark the checkbox. Give Windows a minute or two to activate the feature. Once it's done, click the restart machine button that appears next.

Enabling the WSL feature

Next, go to the Windows Store and install Ubuntu. The first Ubuntu option will install the latest versions. Other Ubuntu options allow you to install an older supported version.

Microsoft Store Linux

Once the installation is complete, you'll need to launch it from the menu. Since this is the first time, you’ll need to wait for the Ubuntu image to be downloaded and installed on your machine. This is a one-time step. The next time you launch, you’ll access the Linux Shell right away.

Once the image installation is complete, you’ll be prompted to create a new root user account inside this shell:

Installing Ubuntu in the command line

After you’ve created your credentials, feel free to type any Linux command to confirm you’re truly accessing a native Linux shell:

Ubuntu usage commands

You’ll be pleased to note that git, python3, ssh, vim, nano, curl, wget and many other popular tools are available out of the box. In a later section, we'll use sudo apt-get command to install more frameworks. First, let's look at several ways we can access this new Linux shell terminal interface. It's probably a good idea to upgrade currently installed packages:

$ sudo apt-get update && sudo ap-get upgrade

Accessing Linux Shell Interface

The are several interesting ways of accessing the Linux shell interface.

  1. Go to Windows Menu Start > type "Ubuntu". You can pin it to Start for quicker access

  2. Open Command Prompt or Windows PowerShell and execute the command bash

  3. In Windows explorer, SHIFT + right-mouse click a folder to open a special context menu. Click Open Linux shell here.

  4. In Windows explorer, navigate to any folder you desire, then in the address bar type wsl, then press enter.

  5. In Visual Studio Code, change the default terminal to wsl.

VS Code WSL Terminal

If you come across new ways, please let me know. Let's set up Node.js in the following section.

The post How to Use Windows Subsystem for Linux 2 and Windows Terminal appeared first on SitePoint.



These Are the Best Developer Tools & Services

This sponsored article was created by our content partner, BAW Media. Thank you for supporting the partners who make SitePoint possible.

As you've learned through experience, there's much involved in trying to find the right developers' tools or services for the task at hand.

It's a challenge. More and more software products and services are appearing on the market. But, every year it doesn't get any easier. This can be especially true in some cases. One case is where app developers have been trying to bridge the gap between software development and operations.

As you will see, open-source solutions go a long way toward resolving some of these problems. There are services that developers can use and that way can save them both time and money.

That's the case with the 6 products and services described below.

The post These Are the Best Developer Tools & Services appeared first on SitePoint.



3 Ways Attack Simulations Can Protect Enterprises Against Advanced Persistent Threats

Enterprises face the tough challenge of ensuring the security of their IT infrastructure. Data breach attempts have now become commonplace

3 Ways Attack Simulations Can Protect Enterprises Against Advanced Persistent Threats on Latest Hacking News.



Apple Inadvertently Reversed A Patch That Lead To iOS 12.4 Being Jailbroken

Apple released its iOS 12.4 in the previous month while fixing a Walkie-Talkie bug breaching user’s privacy. However, little did

Apple Inadvertently Reversed A Patch That Lead To iOS 12.4 Being Jailbroken on Latest Hacking News.



Python Numpy Matrix Multiplication

In this tutorial we will see python matrix multiplication using numpy (Numerical Python) library.

For using numpy you must install it first on your computer, you can use package manager like pip for installing numpy.

Numpy provide array data structure which is almost the same as python list but have faster access for reading and writing resulting in better performance. We will use numpy arrays to represent matrices.

To perform matrix multiplication of matrices a and b , the number of columns in a must be equal to the number of rows in b otherwise we cannot perform matrix multiplication.

We must check this condition otherwise we will face runtime error.

There is * operator for numpy arrays but that operator will not do matrix multiplication instead it will multiply the matrices element by element.

Here is an example with * operator:

# Import numpy 
import numpy as np

def printMatrix(a):
    
    # Printing matrix
    for i in range(0,len(a)):
        for j in range(0,len(a[0])):
            print(a[i][j],end = " ")
        print()

def main():
    
    # Declaring our matrices using arrays in numpy
    a = np.array([[1,2,3],[3,4,5],[5,6,7]])
    b = np.array([[1,2,3]])
    
    print("Matrix a :")
    printMatrix(a)
    print()
    
    print("Matrix b : ")
    printMatrix(b)
    print()
    
    # Using * operator to multiply
    c = a*b
    
    # Printing Result
    print("Result of a*b : ")
    printMatrix(c)

main()

Output:

Matrix a :
1 2 3
3 4 5
5 6 7

Matrix b :
1 2 3

Result of a*b :
1 4 9
3 8 15
5 12 21

Python Numpy Matrix Multiplication

We can see in above program the matrices are multiplied element by element. So for doing a matrix multiplication we will be using the dot function in numpy.

We can either write

  • np.dot(a,b)
  • a.dot(b)

for matrix multiplication here is the code:

# Import numpy 
import numpy as np

def printMatrix(a):
    
    # Printing matrix
    for i in range(0,len(a)):
        for j in range(0,len(a[0])):
            print(a[i][j],end = " ")
        print()
    
    

def main():
    
    # Taking rows and columns of a 
    m = int(input("Enter rows in a : "))
    n = int(input("Enter columns in a : "))
    
    # Taking rows and columns of b
    p = int(input("Enter rows in b : "))
    q = int(input("Enter columns in b : "))
    
    # Checking necessary condition for matrix multiplication
    if n!= p:
        print("Number of columns in b must be equal to rows in b")
        exit()
    
    # Initializing a and b list
    a = [ [0 for i in range(0,n)] for j in range(0,m) ]
    b = [ [0 for i in range(0,q)] for j in range(0,p) ]
    
    # Taking input list a
    print("Enter matrix a : ")
    for i in range(0,m):
        for j in range(0,n):
            a[i][j] = int(input("Enter element a[" + str(i) + "][" + str(j) + "] : "))
    
    # Taking input list b
    print("Enter matrix b : ")
    for i in range(0,p):
        for j in range(0,q):
            b[i][j] = int(input("Enter element b[" + str(i) + "][" + str(j) + "] : "))
    
    
    # Converting python list in numpy array
    a = np.array(a)
    b = np.array(b)
    
    print("Matrix a :")
    printMatrix(a)
    print()
    
    print("Matrix b : ")
    printMatrix(b)
    print()
    
    # Using dot operator to multiply
    c = a.dot(b)
    
    # Printing Result
    print("Result of a*b : ")
    printMatrix(c)


main()

Output:

Enter rows in a : 2
Enter columns in a : 3
Enter rows in b : 3
Enter columns in b : 2
Enter matrix a :
Enter element a[0][0] : 2
Enter element a[0][1] : 3
Enter element a[0][2] : 4
Enter element a[1][0] : 1
Enter element a[1][1] : 2
Enter element a[1][2] : 3
Enter matrix b :
Enter element b[0][0] : 4
Enter element b[0][1] : 5
Enter element b[1][0] : 1
Enter element b[1][1] : 6
Enter element b[2][0] : 9
Enter element b[2][1] : 7
Matrix a :
2 3 4
1 2 3

Matrix b :
4 5
1 6
9 7

Result of a*b :
47 56
33 38

Here the output is different because of the dot operator. Alternatively we can use the numpy matrices method to first convert the arrays into matrices and then use * operator to do matrix multiplication as below:

# Using * operator to multiply
c = np.matrix(a)*np.matrix(b)

Comment below if you have any queries related to python numpy matrix multiplication.

The post Python Numpy Matrix Multiplication appeared first on The Crazy Programmer.



First‑of‑its‑kind spyware sneaks into Google Play

ESET analysis breaks down the first known spyware that is built on the AhMyth open-source espionage tool and has appeared on Google Play – twice

The post First‑of‑its‑kind spyware sneaks into Google Play appeared first on WeLiveSecurity