Putting Gears In Motion: Animating Cars With HTML And SVG

Original Source: https://smashingmagazine.com/2023/02/putting-gears-motion-animating-cars-with-html-svg/

Hello! And if you like HTML, you’ve come to the right place!

I love HTML. As an old-school front-end developer, I think it’s a hugely underrated skill. I’ve been writing HTML since ~2005, and today the browser alone can almost do all the things Flash could do nearly two decades ago!

One such trick HTML now has is called <animateMotion> — those familiar with Flash will remember this as The Motion Guide. I found this video from 14 years ago, but the method existed for a while before that:

The idea is, you create a path for elements to follow… and that’s it!

Here’s an example of what you can do with <animateMotion>:

🚀 Live Preview
⚙️ Repository

If you take a look at the MDN Docs, you’ll see a simple example of a red circle following a path on an infinite loop. The race cars in the live preview follow the same simple rules, and it works just like this!

A simple example of what can be achieved using animateMotion. (See animation)

SVG Using animateMotion

Here’s a simplified version which I’ll use to explain some of the finer details.

Note: I’ve removed some of the path values for brevity, but you can see src for the below snippet at simple-version.html.)

<!DOCTYPE html>
<html>
<head>
<title>Simple Example</title>
</head>
<body>
<main>
<svg viewBox=”0 0 307 184″ xmlns=”http://www.w3.org/2000/svg”>
<g id=”track”>
<g id=”track-lines”>
<path fill=”none” stroke=”#facc15″ d=”M167.88,111.3…” />
</g>

<g id=”pink-car”>
<animateMotion dur=”4s” repeatCount=”indefinite” rotate=”auto” path=”M167.88,111.3…” />
<path fill=”#EC4899″ d=”M13.71,18.65c0.25-0.5…” />
</g>
</g>
</svg>
</main>
</body>
</html>

The first thing to look at is the <g> element with the id of track-lines. This is the yellow dashed line that represents the path the car will follow.

You’ll also see another <g> element with the id of pink-car. Within this group is the <animateMotion> element. It has an attribute of path. The numbers used to form this path are the same as the numbers that form the track-lines. An <animateMotion> element is invisible, and its only purpose is to provide a path for an element to follow.

Speaking of which, below the <animateMotion> element is another <path> element, this is the pink car, and it will follow the path of its nearest neighbor.

animateMotion Attributes

There’s some additional attributes that the <animateMotion> element accepts; these are as follows:

dur: The duration of the animation.
repeatCount: The number of times the animation should loop.
rotate: This can be considered as an orientation to the path. It will ensure the element that’s animating around the path always faces the direction of travel.
path: As explained, this is the actual path an element will follow.

The MDN Docs show the <animateMotion> element as a child of an Svg <circle> shape e.g:

<circle r=”5″ fill=”red”>
<animateMotion
dur=”10s”
repeatCount=”indefinite”
path=”M20,50 C20,-50 180,150 180,50 C180-50 20,150 20,50 z” />
</circle>

Whilst this approach works for shapes, it will only work if the element can accept a child. The SVG path element can’t, so wrapping everything in the <g> element allows HTML to work out where the coordinate system should start and which elements should follow the path. Sneaky ay!

And that’s it. I designed the track and the other elements seen on the preview link in Adobe Illustrator and exported the whole thing as an SVG. I then did a little bit of manual refactoring to ensure the cars were adjacent to an <animateMotion> element. Et voilà! A race track!

Accessibility

One small snag, the <animateMotion> element doesn’t natively observe prefers-reduce-motion. To work around this in the preview I’ve added a media query that sets any element with the class name of car to display: none;. Not ideal, but it is at least motion safe!

I hope you’ve enjoyed this post, and if you have any questions, please come and find me on Twitter. @PaulieScanlon, oh and if you’re a better illustrator than I am, please, feel free to re-design the race track and cars, and I’ll be happy to convert it into code!

See you around the internet!

Further Reading On SmashingMag

“How To Build A Real-Time Multi-User Game From Scratch,” Martin Grubinger
“Easy SVG Customization And Animation: A Practical Guide,” Adrian Bece
“Composable CSS Animation In Vue With AnimXYZ,” Ejiro Asiuwhu
“A Guide To Keyboard Accessibility: HTML And CSS (Part 1),” Cristian Díaz

How To Get a User’s IP Address With PHP

Original Source: https://1stwebdesigner.com/how-to-get-a-users-ip-address-with-php/

In PHP, there are several methods to retrieve a user’s IP address. We will explore two of those ways in this article.

UNLIMITED DOWNLOADS: 500,000+ WordPress & Design Assets
Sign up for Envato Elements and get unlimited downloads starting at only $16.50 per month!

DOWNLOAD NOW

 

The most reliable way to get a user’s IP address in PHP is to use the $_SERVER superglobal variable.

The $_SERVER superglobal variable contains information about the server environment, including the user’s IP address. Here’s an example:

<?php
$ip = $_SERVER[‘REMOTE_ADDR’];
echo $ip;
?>

The $_SERVER[‘REMOTE_ADDR’] element returns the IP address of the client (i.e., the user’s device) that is making the request to the server. This method works well for most cases, but there are a few situations where it may not return the correct IP address, such as when the user is behind a proxy server or using a VPN.

To handle these cases, it is recommended to use the following code to get the user’s IP address:

<?php
function get_client_ip() {
$ip = ”;
if (isset($_SERVER[‘HTTP_CLIENT_IP’])) {
$ip = $_SERVER[‘HTTP_CLIENT_IP’];
} elseif (isset($_SERVER[‘HTTP_X_FORWARDED_FOR’])) {
$ip = $_SERVER[‘HTTP_X_FORWARDED_FOR’];
} else {
$ip = $_SERVER[‘REMOTE_ADDR’];
}
return $ip;
}

$ip = get_client_ip();
echo $ip;
?>

In this code, we first check if the $_SERVER[‘HTTP_CLIENT_IP’] element is set. If it is, we use its value as the user’s IP address. If not, we then check if the $_SERVER[‘HTTP_X_FORWARDED_FOR’] element is set. If it is, we use its value as the user’s IP address. If neither of these elements is set, we use the $_SERVER[‘REMOTE_ADDR’] element as the user’s IP address.

This method provides a more robust solution for retrieving the user’s IP address, as it takes into account the possibility that the user may be behind a proxy server or using a VPN.

Learn more here.

17 Best PayPal Alternatives for 2023: Top Solutions Reviewed

Original Source: https://ecommerce-platforms.com/articles/paypal-alternatives

PayPal was once one of the most revolutionary pieces of technology in the world. Back in the late 1990s and early 2000s, there wasn’t much interest in PayPal alternatives.

That’s because PayPal not only allowed you to send and accept money from friends and family, but it ensured that the money was far safer than many other options you could choose from. This came in handy once eBay emerged, considering both sellers and buyers were concerned about fraudulent activity.

In addition, PayPal has some solid invoicing, ecommerce, payment processing and reporting tools, letting you accept payments for services and products without any problems. It’s no secret that the PayPal interface is still pretty solid, but younger, more agile competitors have drastically improved upon what PayPal initially built. And one of the main reasons PayPal is still so popular is that people are just accustomed to it. Yet, several other PayPal alternatives are available with lower rates, better customer service, and even stronger interfaces.

The Best PayPal Alternatives

Here’s a quick list of the best PayPal alternatives. Each link leads you to the more in-depth reviews of each one.

Square – Best PayPal Alternative for Businesses

Shopify Payments – Best PayPal Alternative for Ecommerce

Payline – Best for Interchange Pricing

Wise – Best for Personal Use and International Payments

Verifone – Best for Global Payments

Payoneer – Best PayPal Alternative for Freelancers

Skrill – Best PayPal Alternative for High-risk Industries

Stripe – Best PayPal Alternative for Small Business

Google Pay – Best PayPal Alternative for Consumer Shopping

Authorize.Net – Best for Top-notch Customer Support

QuickBooks Payments – Best PayPal Alternative for Easy Taxes and Expense Tracking

Dwolla – Best PayPal Alternative for Bank Transfers

Braintree – Best for Customizing Your Payment Processor

WorldPay -Another Great Alternative for Global Payments

Amazon Pay – Best PayPal Alternative for Online Selling and Shopping with Saved Payment Methods

Klarna – Best PayPal Alternative for Customers To Pay in Installments

WePay – Best Alternative for Crowdfunding

Btw, here’s a video version of the tutorial created by my colleague Joe. 🙂

YouTube video

Square – Best PayPal Alternative for Businesses

Square is a PayPal alternative

Square is one of those prominent alternatives that often comes up whenever you’re comparing PayPal with other solutions. And there’s a good reason.

You see, Square is not just a regular payment processor. It offers an online store plus domain for free, and then combines that with shopping cart integrations, as well as invoicing, card data storage vault, and virtual terminal features. And for card processing, you get POS and mobile POS integrations for free.

Although Square doesn’t support selling in as many countries as PayPal, the list is strong and growing:

US

Canada

Australia

Japan

United Kingdom

Republic of Ireland

France

Spain

So the locations are a bit limited, but merchants in those areas benefit from a full online processing suite with notable add-ons like invoicing, marketing tools, social media integrations, loyalty programs, and even standard banking options.

As far as transaction fees are concerned, Square maintains the standard rates we’ve seen with most other processors. In-store card processing, for instance, has a 2.6% + $0.10 transaction fee, while online and invoiced payments cost 2.9% plus $0.30 per transaction.

All in all, Square provides top-notch value as a payment processing solution.

Pros

It comes with a free domain and online store. This is one of the very few online stores you can get for free with no stipulations. It’s also very easy to set up.

Square is a comprehensive all-in-one payment solution.

There are extra add-on services for growing businesses.

Square does not charge any monthly fees.

The features are particularly favorable to low-volume merchants.

They’re transparent with transaction fees, and stick to industry-standard rates, which are pretty affordable.

Send invoices to clients.

Manage your business banking through the same company.

You can customize every aspect of your checkout with the Developer documentation and API.

You get plenty of free hardware from Square and have the option to purchase more hardware.

Cons

As a payment gateway, Square is only available in 8 countries at the time of this article.

Some users complain about the quality and color of Square card swipers, saying the standard white color gets dirty easily, and it occasionally lags when processing cards.

It’s not ideal for high-risk merchants. In fact, you probably won’t even get accepted.

Who is it Best For?

As a PayPal alternative, Square works best for businesses accepting payments online or in-person. Not only do you get a free online store, but Square offers smooth payment processing with reasonable fees, a physical card swiper for accepting payments in the real world, and a variety of add-on services made just for businesses.

Read our full Square Review here. 

Go to the top

illustration of a cat climbing a ladder

Shopify Payments – Best PayPal Alternative for Ecommerce

Shopify Payments is a paypal alternative

If you’ve used Shopify to build and manage an online store, you’re probably familiar with Shopify Payments. It’s a built-in payment processing system that comes by default as part of the whole Shopify platform.

Therefore, you don’t have to worry about integrating with an external payment gateway. You can simply manage your transaction processing system right from Shopify’s main dashboard. The result is a one-dashboard management system for payments, inventory management, and website design.

And Shopify Payments is not only about online payments. It also offers POS hardware to support in-store payments and sync those transactions with an online store.

Another reason Shopify Payments stands out is because of its 0 transaction fees and tiered credit card fee system (that gets cheaper as your business grows). While using PayPal on Shopify costs 0.5-2% in transaction fees, and that’s before the credit card fees (usually around 2.9% +$0.10 per transaction). Shopify Payments offers 0 transaction fees. And it’s the easiest payment gateway to install on the Shopify ecommerce platform.

In addition, the extra credit card fees get capped at 2.9% + $0.30 per transaction, and they go as low as 2.4% + $0.30 depending on your Shopify plan. Learn more about Shopify pricing here.

Finally, Shopify Payments sends payment to your bank account in as little as 1 day, with final funds landing in your account in 1-4 days. PayPal takes about 5-7 business days.

Pros

It’s built into the Shopify ecommerce platform to offer a seamless payment management experience.

Shopify Payments has 0 transaction fees and decreasing credit card rates as your business grows.

You get your funds much faster with Shopify Payments than PayPal.

It works well with many accounting applications to help with accounting and reporting.

You can accept all the standard payment methods, along with alternative methods like Google Pay and Apple Pay. It’s even possible to still add a PayPal button on your store.

It’s one of the easiest payment gateways to configure, seeing as how the sign-up process only takes a few minutes after you type in banking information.

The Shop Pay feature lets customers save their payment and contact information for rapid checkouts later on. Shop Pay data is also useful on other merchant websites.

Cons

You can only install Shopify Payments if you use the Shopify ecommerce platform for your online store.

Shopify Payments is only available in a few countries.

There have been user reports of accounts getting frozen without warning.

Who is it Best For?

Shopify Payments works well for online stores, period. It’s a wonderfully simple payment processor (powered by Stripe) through the Shopify ecommerce platform. That means we can really only recommend it to merchants who use Shopify as their ecommerce platform. So, if you currently use Shopify, or plan to switch to the platform in the future, Shopify Payments makes a significant amount of sense because of its extremely low fees (based on your payment plan), seemless integration with Shopify, and fast approval.

Read our complete Shopify Payments review.

Go to the top

illustration of a cat climbing a ladder

Payline – Best for Interchange Pricing

Payline

Payline is a payment processor that offers a diverse range of solutions, including mobile, online and in-store payments.

Payline works as one of the best PayPal alternatives for both online and in-person payments. It’s cheaper and way more flexible than PayPal, particularly for in-person transactions.

Payline does not use a standard static pricing schedule, allowing for a more transparent, flexible fee structure. They accomplish this through an interchange plus pricing system, where the fees vary consistently based on the payment methods you end up processing.

That said, the interchange model is, undeniably, the most transparent in the payment processing space. The only challenge you might face, however, is forecasting your future expenses.

PayPal fees have increased over the years (reaching around 3.49% + a fixed fee for online transactions), so you’re bound to incur less with Payline.

Now, the features you get for card processing depend on the package you settle for. If a mobile card reader is your kind of thing, then Payline’s mobile app and card reader packages work well. They also have options for invoicing, scheduling, recurring billing, and full POS systems, all of which are affordable and well-tailored for small business owners.

Here’s a general idea of how Payline pricing works:

In-person: Interchange + 0.2%, which means $0.10 per transaction and a $10 per month fee (this is the interchange calculation) plus an extra 0.2%.

Online: 0.4%, or $0.02 per transaction with a $20 per month fee, plus 0.4%.

Taht may sound a little confusing, but it often ends up saving merchants a significant amount of money. And Payline has a payment calculator to predict your fees.

Pros

The interchange plus pricing structure is not only flexible but also very transparent.

Payline offers a wide range of in-store credit card processing packages, complete with robust hardware.

Payline’s offline transaction fees are cheaper than PayPal’s. It’s also almost always cheaper to use Payline for online transactions.

It offers a fully featured API to integrate with third-party solutions and platforms.

Payline supports mobile payments and offers wonderful mobile payment hardware.

You can integrate with most popular ecommerce platforms.

Send invoices, or create plans for recurring billing and scheduling.

The deposit speed ranges from 1 to 2 business days.

Cons

So far, Payline is only available in the U.S.

It’s difficult to forecast the fees you stand to incur through the interchange plus pricing model.

Payline’s ecommerce payment processing features don’t match up to PayPal’s.

Who is it Best For?

Payline boasts a transparent interchange fee structure for online store transactions, invoices, recurring payments, and in-person payments, making it ideal for those who are looking for a deal and a full view as to how much they’re being charged for their payment processing.

Read our Payline Data review.

Go to the top

illustration of a cat climbing a ladder

Wise – Best for Personal Use and International Payments

Wise (formerly known as TransferWise) is a much cheaper alternative to PayPal for international transfers (see their comparison tool vs PayPal). Their multi-currency, borderless account helps consumers, freelancers, and online businesses send, receive, and spend money across borders with minimal fees.

Wise works like this: It cuts out sneaky hidden charges and sticks to one upfront transfer fee. It’s also interesting how the money gets moved around. For instance, let’s say you’re in the US and want to send money to a friend in France. You make the payment and the money goes into Wise’s American bank account. It then pays your friend from the Wise France bank account using the real exchange rate. Therefore, the money never actually crosses borders—keeping rates even lower and making the transfers rather fast.

Wise has made a name for itself in the international transfer game, but it also provides an international business banking account for ecommerce. This means you can accept cross-border payments for services and goods, while also linking to Stripe and Amazon for additional payouts.

Pros

Wise is one of the most accepted and cheapest tools for making international money transfers.

You can accept payments for services and products without the high fees from PayPal.

During our testing, Wise was often close to 19x cheaper than PayPal.

Distribute payments to multiple international contractors in one click.

Wise has payment links to send clients.

Very transparent pricing.

Their borderless account allows you to hold and transfer more than 40 currencies.

With Wise for business you can invoice your customers in the currency that works for them. This feature also has a debit card, API, and support for over 70 countries.

The money never actually crosses borders, so you can keep down costs and ensure fast transfers.

Cons

You must have a bank account to receive a transfer. However, payments are possible with ACH, wire transfer, debit card, credit card, ACH, or one of the many digital wallets.

You can only receive money in EUR, USD, AUD, and GBP with the borderless account.

Wise isn’t a payment gateway that you would install on your ecommerce store. It’s more for freelance and contract payments, or if you plan on invoicing for B2B transactions. It also makes sense when paying suppliers.

Who is it Best For?

Wise dominates PayPal when it comes to fees. Not only do they provide complete transparency when making transfers, but they cut out the usual fees that come with sending and receiving international money through PayPal. This makes it ideal for personal money transfers (international or domestic), and for accepting payments for freelancing and contracting work. Essentially, you’re able to eliminate many of the fees associated with PayPal invoicing, and we’ve yet to find a less expensive alternative besides Wise.

Read our full Transferwise Review here. 

Go to the top

illustration of a cat climbing a ladder

Verifone – Best for Global Payments

verifone

Verifone (formerly 2Checkout) is one of our favorite PayPal alternatives, mainly because it’s all about accepting payments globally. As we said a bit about PayPal in the introduction, you’re still somewhat limited to the countries you can accept payments from through PayPal. Verifone looks to change that. The fees in the US are exactly the same as PayPal, but we’ve found that other countries enjoy better rates when accepting payments from customers. You can calculate the payment pricing to see if Verifone is more affordable than PayPal in your country.

As for ecommerce processing, Verifone provides an excellent shopping cart tool to sell digital goods online. Its retail module has options to accept payments online, in-person, and or anywhere you want. With support for over 200 countries, and a dashboard that’s easier to understand than PayPal’s. we highly recommend Verifone, especially for global payment processing.

Pros

You don’t have to pay any monthly or setup fees.

Accept major payment methods, including credit cards, debit cards (Visa, MasterCard, Maestro), and PayPal.

Choose from 87 currencies, eight payment types, and 15 languages. There’s support for selling from over 200 countries.

The advanced fraud protection goes through over 300 security rules for each transaction.

Several customizable checkout options are available. The checkouts are also mobile-friendly, branded, and localized.

Setup recurring billing for your customers.

Connect your merchant account with a payment gateway.

Integrations include over 100 online carts, an API, and a sandbox.

Cons

The transaction fees aren’t the lowest you’ll find: 3.5% + $0.35 for the 2Sell plan.

$20 is charged on your account for all chargebacks.

The average fee for currency conversion is 2-5% above the daily bank exchange rate.

The digital goods plan has a transaction fee of 6% + $0.60, which is far too high.

Verifone is one of the best alternatives to PayPal, and we mainly like it because of its international payment support. It doesn’t matter where you’re located, so you shouldn’t have any problems.

Who is it Best For?

Whether you’re selling products through online retail, or you run a store with digital goods, Verifone handles global payments with ease. It’s not the least expensive option on this list, but we’re impressed by its support for over 200 countries, 15 languages, and 8 payment types, along with its advanced security to minimize international fraud attempts.

Read our Verifone review for more info.

Go to the top

illustration of a cat climbing a ladder

Payoneer – Best PayPal Alternative for Freelancers

Payoneer is one of the top PayPal alternatives

Payoneer looks somewhat similar to Skrill (listed below) since you get a debit card and an online account. Shopping online is a breeze, and sending and receiving money only takes one step. The main benefit is with the debit card. Going to the ATM is possible, and you can also walk into a brick and mortar store to use your Payoneer account.

Payoneer has also expanded into the global payments market, offering tools for getting paid and sending payments to and from clients and marketplaces.

In terms of ecommerce payments, Payoneer functions more like Wise, where you can create a payment link and accept international transfers from customers, but it’s not a complete payment processor that you’d add to a shopping cart.

Pros

It has some handy tools and integrations for freelancers who would like to accept money from clients. This is particularly true for international payments.

You can use Payoneer anywhere in the world.

The transaction process doesn’t require any programming knowledge. You can implement the system on your website and get your money fast.

It also doesn’t take long to set up an account.

Getting access to your funds is easy through your own bank account or through an ATM.

The pricing is simple (monthly billing) and great for payments between Payoneer accounts (it’s free).

Request payments with your own payment link and set up receiving accounts for contractors and suppliers.

Cons

The jury is still out on the customer service. Many people online say it’s not that great.

When transferring to a bank account, you generally have to pay a fee. This is a huge downside since most other systems like PayPal have this for free.

You won’t find any payment gateway with Payoneer.

Accepting credit cards will result in a high fee.

If you go to the ATM you should expect to pay a large fee.

Who is it Best For?

Although we primarily recommend Wise for freelancers, Payoneer also has a solid reputation for those freelancers that need to send out invoices and cut down on the outrageous fees imposed by PayPal. Essentially, Payoneer allows you to bypass high processing fees and international conversion fees. It’s easy to transfer money to workers around the globe, while also accepting payments from other countries.

Go to the top

illustration of a cat climbing a ladder

Skrill – Best PayPal Alternative for High-risk Industries

Skrill

With similar rates and fees as PayPal, the Skrill platform may seem the same at first. However, the prepaid debit card and the simple interface are enough to consider Skrill. International payments are far easier with Skrill since the money can be sent and transferred immediately to a debit card that the company sends you. Then you can use the debit card wherever you want, including ATMs.

The Skrill Business account offers unique tools for hosting a quick checkout on your ecommerce store, while also providing digital wallets, rapid transfers, and shopping cart integrations. It’s also possible to connect with the Skrill API for full customization. Along with competitive processing fees and enhanced fraud management, Skrill definitely serves as one of the top PayPal alternatives.

Pros

The account setup is one of the easiest in the business.

The security is solid and offers high-quality fraud and risk management.

Uploading and receiving funds, while also spending money at Skrill merchants, is almost always free.

Users can take their Skrill account around the globe.

All you need to make or accept a payment is an email address.

Skrill has a full system set up for gambling and playing games with money, so it’s a good solution for those options.

You can integrate with several ecommerce platforms to offer a friction-less multi-currency payment gateway.

Skrill has digital wallets and rapid transfers to your bank account.

Skrill supports some of the most unique international payment methods, such as HSBC, Oxxo, and CartaSi.

Cons

Sending money to an email address or another Skrill wallet costs 1% of the amount sent, with the charge capped at $10.

The company has rather strict fraud prevention tools, so you may end up finding that your account is frozen. However, this has happened at PayPal too.

Reports have shown that the customer service isn’t the best at Skrill.

Who is it Best For?

Skrill handles global payments, and it offers an intuitive platform for setting up your accounts. The overall idea is not so much to minimize costs but to improve the accessibility to payment processing for international brands and those that work in high-risk industries; think gambling and alcohol—these are industries that often have trouble finding a payment processor to work with.

Read our comprehensive Skrill review.

Go to the top

illustration of a cat climbing a ladder

Stripe – Best PayPal Alternative for Smal Business

Stripe is a PayPal alternative

Stripe is probably the most popular of all the PayPal alternatives, and you’ll notice that some ecommerce platforms state Stripe as their preferred payment processor. For example, Squarespace has been working with them for a long time and now Shopify provides its Shopify Payments system through Stripe. The whole point of Stripe is that it eliminates the need for a merchant account and gateway.

Everything is handled by Stripe, from collecting payments to sending those payments to the bank (including ACH payments and Bitcoin transactions). It’s one of the more streamlined alternatives out there and it’s no wonder so many platforms partner with them. And Stripe has maintained its industry-standard transaction fees (2.9% + $0.30), whereas PayPal has failed to keep those rates.

Pros

Stripe automatically puts your transaction money in a bank account.

Mobile payments are available.

Accept payments from people and companies all over the world.

Real-time fee reporting is available.

Only pay for what you use.

The pricing is fairly transparent, with no setup, hidden, or monthly fees.

Apple and Android Pay are supported.

The fees have remained the same for quite some time.

Collect payments through an online store with one of the easiest to use payment gateways.

You have direct access to an API for customizations and integrations.

Cons

You generally have to wait a few days after a transaction to gain access to the money.

Although you can accept payments from all over the world, merchant accounts are only available to the US, Canada, UK, Australia, and many European countries.

The interface may require some programming knowledge, but that’s usually only when working with the API.

International cards require an additional 1% transaction fee.

Who is it Best For?

Stripe makes so much sense for small businesses because of its welcoming interface, customization options, and the ability to accept payments in-person, online, and all over the world. We also like that payouts happen fast, which is an essential part of of improving cash flow for small businesses. Not to mention, you can integrate Stripe with just about any platform, whether it’s for client invoicing or in your online store.

Read our full Stripe review here. 

Go to the top

illustration of a cat climbing a ladder

Google Pay – Best PayPal Alternative for Consumer Shopping

Google Pay

Google Pay is by far the best choice if you’d like a place to store and use your debit and credit cards. Spending money is easy online, and you can also put all of your cards on your phone for spending at physical locations.

The business portion of Google Pay requires a separate POS and payment processing system, but accepting Google Pay gives your customers a speedier checkout (both offline and online) and more options for payment. There are also plenty of ways to expand your business with Google Pay, including linked offers, enrollment features, and ticketing.

Pros

Google Business allows you to accept Google Pay from your customers, whether it be on your website or a physical store.

It only takes a moment to send out or receive payments.

Sending out payments from your smartphone is the primary feature, and it can be done online or in person.

There aren’t any fees, and your customers don’t get charged anything extra.

Access to the API enables features like enrollment, linked offers, and smart tap.

Cons

It’s still limited to only iPhones and some Android phones.

Many people still question the security of mobile wallets like this.

There’s no payment processing system or shopping cart for businesses.

Who is it Best For?

We recommend that all retail and online merchants accept Google Pay, since it’s simply another payment method for customers. However, the main reason we like Google Pay as a PayPal alternative is for online and in-person shopping. Essentially, Google Pay serves as a digital wallet where you can save your payment methods (like credit and debit cards) and also keep all of those methods safe on your phone. Consumers also enjoy no fees and options to send money to any business or person.

Go to the top

illustration of a cat climbing a ladder

Authorize.Net – Best for Top-notch Customer Support

Authorize.net

The Authorize.Net system is rather popular with online stores, as the platform provides reasonable rates, quality customer service, and an interface that pretty much anyone can use. Although you don’t have the ability to send and receive payments from friends and family, it’s a quality PayPal alternative for those who would like to accept payments and get in on the most widely used gateway on the planet.

Authorize.net has products for ecommerce, point of sale, mobile payments, and phone payments. You can also use its tools for billing, eChecks, and mobile card reading. It’s an incredibly popular payment gateway for international business, since Authorize.net support more countries than competitors like Stripe and Square.

Pros

Over 400,000 merchants use Authorize.Net, so they’ve got to be doing something right.

The reliability and security are far above the competition.

A free mobile app and swiper come along with your account.

The free 24/7 support is the best in the business.

You have the ability to sync with QuickBooks.

There aren’t any setup fees for a payment gateway or merchant account.

Integrate with hundreds of online store builders.

Accept payments through ecommerce stores, phone transactions, and invoices.

Cons

You don’t get the personal finance and sending tools you would get in PayPal.

There’s a monthly gateway fee of about $25.

If you sell globally, add a 1.5% assessment for international transactions.

Chargebacks are $25.

Who is it Best For?

Authorize.net makes sense for a wide variety of reasons, but particularly for accepting payments through an online store. It’s one of the more established payment gateways with advanced security, high-quality customer support, and seemless online payment tools meant to streamline payments for your business. If you’ve ever found payment gateways a pain to deal with, Authorize.net is the answer to your questions. It’s a premium service that gives you far more documentation and support than you would ever get with PayPal or Stripe.

Learn more on our Authorize.Net review here.

Go to the top

illustration of a cat climbing a ladder

QuickBooks Payments – Best PayPal Alternative for Easy Taxes and Expense Tracking

QuickBooks Payments

Intuit could potentially provide you with a whole suite of tools depending on what you need for your business. It’s popular, and you can get paid with the QuickBooks tool. It’s also one of the best solutions if you plan on integrating with QuickBooks for the accounting functionality as well.

Rates remain simple from QuickBooks, with 1% fees for ACH bank payments, 2.4% fees for swiped cards, and 2.9% fees for invoices. Other features include recurring invoices, eCheck support, and contactless payments.

Pros

Integrate with QuickBooks.

Gain access to TurboTax.

Send invoices just like PayPal. You can also make those invoices recurring.

Get paid anywhere with mobile payments.

You can include a Pay Now button on your website. Or integrate with a shopping cart.

Accept ACH bank transfers.

Connect your payments with timesheets and payroll.

Cons

The rates are not competitive enough if you’re not working with QuickBooks.

This isn’t what you would want to go with if you’re only looking for something for your personal sending and accepting.

We also don’t like QuickBooks for most ecommerce setups. It’s best for invoicing.

Who is it Best For?

QuickBooks isn’t an exact alternative for PayPal, but it solves some of the problems you may have when sending invoices, tracking those transactions, and getting them ready for tax time. PayPal is a mess when it comes to taxes, so QuickBooks turns that into an easier process. For freelancers, small businesses, and online stores, QuickBooks is wonderful for invoices, accepting mobile payments, tracking all revenue, and sending it to TurboTax during tax time.

Learn more on our QuickBooks Payments review.

Go to the top

illustration of a cat climbing a ladder

Dwolla – Best PayPal Alternative for Bank Transfers

Dwolla

Dwolla may not initially come up on your radar, but it’s worth a look because it works so similarly to PayPal. Although you do have the ability to send and receive payments from companies and individuals, the best part is that the company specializes in ACH bank transfers. It’s by far your best option if you plan on accepting or sending lots of bank transfers.

Unlike PayPal, Dwolla is not a card processing solution. Instead, it facilitates fund transfers by linking directly with your bank account.

Now, the good thing about eliminating cards is this: the cost of transactions is kept low. In fact, Dwolla’s principal objective is helping everyone with a web-enabled device to send money at the lowest price possible.

And to achieve that, Dwolla does not charge even a cent to process funds under $10. Above that, every single transaction will cost you a fixed rate of $0.25. It really is that simple.

Overall, it makes PayPal’s fees seem outrageously high, especially when you’re handling a large number of transactions. A merchant who happens to process 10 transactions worth $100 each, for instance, would only incur $2.50 with Dwolla. In contrast, PayPal would deduct a close to $40.

Pros

The branding tools are powerful and easy to use.

Making a bank transfer is super easy.

Next day transfers are offered for a flat fee.

The transaction fee is only $0.25, and they offer pay-as-you-go pricing or scale pricing.

You can access the Dwolla API for superior integrations.

Lets the sender pay the transaction fee if needed.

An instant cash transfer is offered.

You can automate mass payouts, like if you’re running a marketplace.

Cons

You can’t make payments if both the sender and receiver aren’t using Dwolla.

You can’t make an account with Dwolla if you’re located outside of the United States. However, it is possible to initiate cross-border payments with the specialty CurrencyCloud feature.

Dwolla Business has monthly fees and they aren’t cheap.

Who is it Best For?

Dwolla makes ACH transfers a breeze. Not only can you tap into the API for customizations, but the standard product works wonders for sending money from bank to bank, especially if you’re handling those types of transactions for freelancing or contracting. Finally, Dwolla keeps fees pretty low, so you musn’t worry about cutting into your revenues just because you have to use an online payment processor.

Read our comprehensive Dwolla review.

Go to the top

illustration of a cat climbing a ladder

Braintree – Best for Customizing Your Payment Processor

Braintree

Along with a payment gateway and recurring billing, the Braintree system provides a way for you to store your credit cards, similar to Google Pay. Although some more personal finance features are packaged into Braintree, we like it best for merchants. 

Braintree is owned by PayPal, but it still runs as a fairly independent company. Having said that, some of the best features and products include the option to accept payments for products and service through an online store, authorization tools for granting permissions to 3rd parties, and marketplace payments.

Pros

The pricing is simple and straightforward.

Collect recurring billing and store credit cards.

Braintree accepts all sorts of payment methods, including PayPal, cards, and Venmo.

You get a far more advanced list of features than you do with PayPal.

The customer support has been known to be rather solid.

Both online and mobile payments are allowed.

The authorization tool lets you grant permission to 3rd parties for seamless integrations and payments.

There’s a special marketplace payments system.

Braintree offers built-in fraud protection, reporting, and data security.

Cons

If you’re planning on implementing Braintree on your website it may require you to have some sort of programming knowledge.

A separate merchant account is required for the system to work.

Although the main fee is for transactions, there is a large list of other fees that you have to think about.

Who is it Best For?

Braintree was built with developers in mind, so it’s definitely a solution we like for companies with custom payment needs. For example, it’s nice for when you want to customize the entire checkout process in an online store. You can also configure recurring billing or store credit cards from payers.

Read our comprehensive Braintree review.

Go to the top

illustration of a cat climbing a ladder

Worldpay (from FIS) – Another Great Alternative for Global Payments

WorldPay - PayPal alternatives

Previously known as RBS Worldpay, this is a payment processing platform that supports a host of payment options, including credit cards and debit cards. Its network extends globally, consequently making it a major PayPal competitor.

The main similarity between the two is that they primarily support both online and offline card transactions. So, you can leverage Worldpay in your ecommerce business as well as in-store, just like PayPal.

When it comes to offline payments, however, it turns out Worldpay is built to support a wide array of channels. You can take advantage of its POS systems plus ATM processing, as well as its mobile payment function to accept credit card payments and cash.

Worldpay then extends the same level of diversity to its pricing schedule, which has been structured to offer both tiered and interchange plus packages. The corresponding amount you end up paying per month depends on both your average monthly processing volume and transaction history.

Pros

Just like PayPal, Worldpay has an extensive global payment network.

It supports a host of offline processing options.

The pricing schedule is flexible.

You can take advantage of interchange-plus pricing for increased transparency.

Worldpay offers 24/7 customer support.

You can take, make, and manage payments from one dashboard.

They even have robust wealth management and capital services.

Cons

Terminating the service early will cost you a fee of $295.

You have to commit to a contract for three years.

Its free terminal offer is misleading.

You must contact a salesperson before signing up for an account.

The website isn’t all that intuitive, making the offerings seem hidden or hard to find.

Who is it Best For?

Similar to Verifone, Worldpay manages global payments with its extensive global payment network. This results in a transparent, interchange fee structure, along with a pricing schedule that’s flexible, allowing you to keep an eye on how much is being spent on payment processing. Overall, it’s a nice option for international payments, whether you’re accepting those payments through an online store, offline, or through invoices. You can even move your money to Worldpay’s wealth management services.

Learn more on our WorldPay full review.

Go to the top

illustration of a cat climbing a ladder

Amazon Pay – Best PayPal Alternative for Online Selling and Shopping with Saved Payment Methods

Amazon Pay - PayPal alternatives

To let people checkout of your online store, Amazon Payments is at the top of the list. It expedites the whole process, similar to something like PayPal (but not ACH payments or bitcoin transactions). We like to compare it to a Facebook login, where all of the user information is already stored. Therefore, the login, or checkout (with Amazon Payments) is going to be much faster than that of a regular shopping cart and checkout.

On the other side of the transaction, Amazon Pay helps merchants keep customers engaged while also reducing chargebacks and fraud. You can integrate an Amazon Pay button into your online store to accept payments with ease. It’s also possible to use for in-store payments.

Pros

The transaction fees are lower than PayPal.

The security is very advanced compared to other competitors.

If you start with an Amazon account, the interface and signup process is easy.

Everyone is familiar with Amazon, so your customers will have it easy when paying.

Amazon Pay integrates well with most ecommerce platforms.

Merchants can offer a one-click payment process for customers with Amazon accounts.

Cons

There are some random fees like domestic processing fees and cross-border processing fees.

Integrating with your online store may take a little programming knowledge, but many payment gateways, like Stripe, make it easy to integrate with Amazon Pay.

Who is it Best For?

Amazon Pay is a winner for both merchants and shoppers, because it allows customers to save their payment details and log into their accounts with one click. This way, they have a more secure storage solution, and they don’t have to type in their payment credentials whenever they want to make a purchase from an online store. What’s more is that online merchants can add Amazon Pay as a separate payment option (like you would with PayPal or Google Pay), giving customers the option as to how they want to checkout.

Go to the top

illustration of a cat climbing a ladder

Klarna – Best PayPal Alternative for Customers To Pay in Installments

Klarna - PayPal alternatives

Klarna offers personal finance and business tools for paying however you like, finding deals, and processing payments from customers. The idea behind Klarna’s business tools is to convert and retain customers with unique payment options like financing and installments. Overall, Klarna isn’t exactly a direct competitor of PayPal, but it gives customers another, more flexible payment option.

The entire customer financing process is made possible by Klarna’s AI system, which quickly analyzes an individual’s potential risk based on their details, as well as the time of purchase, and transaction history. It subsequently approves or denies the purchase within a couple of seconds, and then order fulfillment follows. Ultimately, the customer is given 14 days to clear the payment.

Well, this means that while customers are able to shop conveniently, most of the risk is incurred by Klarna. In other words, this payment processor is deeply involved in your ecommerce order fulfillment process.

Interestingly, you don’t even have to sign up with the service to connect directly with banking. You can simply proceed with your standard online banking details plus authentication, and voila! Payment is immediately transferred to the merchant account.

Compare that with the inconvenience of registering on PayPal and then loading your account, before you’re finally able to conduct transactions.

Pros

Customers can purchase products and complete the payment after delivery.

The checkout process is conveniently easy.

Shoppers are allowed to pay for their orders in installments.

Customers don’t have to pay for anything in the event products are returned.

Merchants are paid by Klarna upon checkout.

Cons

Purchases can be declined without any concrete reason.

Klarna’s customer support is not adequately responsive.

Customer refunds might take some time.

Who is it Best For?

Sure, Klarna offers features for customers to find deals, but it’s primarily a way for online shoppers to pay in installments. We like this for merchants that sell more expensive items, considering you can give your customers an easier way to purchase your products. Not only that, but getting listed on the Klarna app means that you’re more visible to shoppers who use Klarna.

Read our comprehensive Klarna review.

Go to the top

illustration of a cat climbing a ladder

WePay – Best Alternative for Crowdfunding

wepay - PayPal alternatives

Launched to compete directly with PayPal, WePay is a card processing solution that focuses mainly on online payments.

Owned by Chase, WePay offers integrated payment systems for online marketplaces, POS systems, and software companies. The API-first development process means you can integrate WePay in with all of your tools. You can also look forward to same-day deposits, a customer risk engine, and integrations with platforms like Meetup, Constant Contact, and Bigcommerce.

Pros

WePay provides a flexible API.

You can get your account up and running pretty quickly.

It’s well-tailored for crowdfunding.

WePay supports a diverse range of online payment options.

ACH payment processing is cheap.

There are no monthly charges to use WePay.

It integrates with quite a few email marketing and finance tools.

You can accept in-person payments with direct integrations to your POS.

Cons

It can’t accept funds from PayPal.

The WePay ecommerce features are not as robust as PayPal’s

The ecommerce platform integrations are somewhat limited.

Who is it Best For?

WePay serves as a viable online payment processor, but its primary draw is its extra tools for crowdfunding. Not only can you accept ACH transfers for your crowdfunding campaigns, but you can list a variety of payment methods from credit cards to checks. There’s even a way to accept in-person payments.

Read our comprehensive WePay review.

Go to the top

illustration of a cat climbing a ladder

Which PayPal Alternative Should You Choose?

It makes sense that some folks used to be hesitant to move away from PayPal because compatibility issues were always arising. However, that’s not really the case anymore, and you can actually find more reliable solutions for doing business in different parts of the world.

PayPal’s rates aren’t nearly as competitive as some options out there, and PayPal has seen its fair share of lawsuits. We’re not saying you should write off PayPal altogether, but it’s not a bad idea to get a taste of the best PayPal alternatives. Who knows? You may end up saving a significant amount of money and be happier with the company you choose.

Some of the options talked about above are better for personal sending and receiving, while others are best for ecommerce payments. On the other hand, you may just be looking to collect and send ACH bank transfers. If you want a PayPal duplicate, go with Dwolla or Skrill. If you’d like to complete transactions in any country, consider 2Checkout. Google Checkout is nice for storing cards, while Authorize.net, Square, and Stripe are favorites for ecommerce transactions.

However, Wise is by far the best for international payments, whether for invoices or paying workers.

If you have any questions about the best PayPal alternatives above, feel free to drop a line in the comments below.

The post 17 Best PayPal Alternatives for 2023: Top Solutions Reviewed appeared first on Ecommerce Platforms.

Discovering Primitive Objects In JavaScript (Part 1)

Original Source: https://smashingmagazine.com/2023/02/discovering-primitive-objects-javascript-part1/

It seems natural to use strings to distinguish things. It’s very likely that in your codebase, there are objects with name, id, or label properties that are used to determine if an object is the one you’re looking for.

if (element.label === “title”) {
make_bold(element);
}

At a certain point, your project grows (in size, importance, popularity, or all at once). It needs more strings as there are more things to distinguish from each other. The strings grow longer, as does the cost of typos or, say, your label naming convention changes. Now you have to find all the instances of those strings and replace them. Consequently, a commit for that change becomes much bigger than it should be. Which makes you look better in the eyes of the clueless. Simultaneously it makes your life miserable since it’s much harder now to find the cause of regression in your git history.

Strings are bad for identification. You have to consider uniqueness and typos; your editor or IDE won’t check if it’s the string you meant. It’s bad. I hear someone saying, “Just put them in a variable, duh.” That’s a good suggestion, and it removes some of my concerns. But look at John Smith:

const john_smith_a_person = “John Smith”;
const john_smith_a_company = “John Smith”;

// Do they have the same name?
john_smith_a_person === john_smith_a_company; // true

// Are they the same thing?
john_smith_a_person === john_smith_a_company; // true

John happens to share the name with a company. What if I say to you I have a better solution? The one that removes all the concerns and adds more value — allows you to achieve more. What would you say? Well, I won’t rewrite the article just because your answer doesn’t fit my narrative. The answer is objects. You use objects themselves to figure out if an object is the one you’re looking for.

// Do they have a same name?
john_smith_a_person.name === john_smith_a_company.name; // true

// Are they the same thing?
john_smith_a_person === john_smith_a_company; // false

It makes the intent clearer. Let me give you a better example. Say you have labels in your app. They are localized, so the label string is determined by the localization library you’re using and your team’s translation process. You keep your labels in a module where you have them all neatly organized and curated. Once you need to do something special for certain labels, you can compare it directly with the one you’ve got.

import React from “react”;
import labels from “./labels.js”;

const render_label(label) => (
<Label
className={label === labels.title ? “bold” : “plain”}
icon={label.icon}
text={label.text}
/>
)

function TableOfContents({ items }) {
return (
<ul className=”my-menu”>
{items.map(render_label(item.label)}
</ul>
);
}

See how much more I can do with objects? In the labels module, I’ve set aside a label title, which in this case should be rendered bold. Plus, being an object, my label can hold a localization string (imaginatively called text) and an icon. It’s all neatly organized in advance, which keeps my UI logic clean.

But it’s just a part of the picture. I know we use objects all over the place, and it’s nothing new to group things in them. But I bet you don’t use them exactly like that. I rarely see two objects being compared like that because you never know what’s in there or where it came from. Objects are created and changed all the time. It is more likely for them to be compared by the values of their properties than the objects themselves. And the reason for that is that objects aren’t suitable for that kind of use. They are too capable. To allow that use case and many others, we have to, on the one hand, reduce some capabilities of objects and, on the other, implement some more. And in the end, we’ll get what I call Primitive Objects. Th… a solution to al… some problems.

In the first part of the series, I want to cover some aspects of JavaScript that help bring objects closer to primitive values, which in return would allow us to benefit from common language features that aren’t usually associated with an object, like comparisons and arithmetic operators. In the following part, we’ll look closely into practical examples and tools to work with such objects. Now let’s see what objects are like in JavaScript.

Properties Of Primitive Values We Need

First, let’s define our goal. Let’s draw a picture of where we would like to be afterward. What properties of primitive values do we want our objects to have?

Immutability
Primitive values are read-only. We want our objects not to be editable by anybody after their creation. Recall the example before. What use of a label do we have if some code out of our control has changed the text or icon of it? Once the object is defined, it should be set in stone.
Work with operators.
Expressions with certain operators return their appropriate type. Arithmetic operators give numbers back. Comparisons give booleans.
Have literal syntax.
Literals for primitives give you the exact value, or rather an object representing the value. Such objects get created once for each value. Each time you have “hello” in your code, you get the same object.
Have types.
The typeof operator tells you what you’re dealing with (except for null). We don’t always know which kind of object we get. So before we poke its properties, it would be nice to know what we’re dealing with.

I listed them by immediate usefulness. And as luck would have it, they are also ordered by easiest to get. In this article, I’ll cover the first one and a part of the second one. We’ll see how to make objects immutable. We also will define their representation in primitive values, which allows us to use some operators on them. Moving from objects to primitive values is easy, as primitive values are objects themselves — sort of.

It’s Objects All the Way Down, Even If It Kinda Isn’t

I remember my confusion when I first saw {} === {}; // false. What is this language that cannot even tell apart two equal things? It felt so ridiculous and amusing. It was much later that I learnt that there are much worse parts in JavaScript, after which I stopped laughing while watching wat talk.

An object is one of the fundamental things in JavaScript. You might have heard that in JavaScript, everything is an object. That’s quite true. Apart from some bottom values, all the primitives are objects. While technically, it is more nuanced, from the perspective of our code, it is true. In fact, it’s true enough that believing everything is an object might be a useful mental model. But let’s first try to understand what is happening with that object-to-object comparison that was so amusing to younger me.

Object literal syntax is used for creating new objects. It allows us to declare and initiate an object in a single expression.

// Instead of this.
const my_object = new Object();
my_object.first_property = “First property”;
my_object.nth_property = “Next property”;

// You can do this.
const my_object = {
first_property: “First property”,
nth_property: “Next property”
};

Much cleaner, right? But now I think the lack of object initialization line is what got me confused about those two empty object equality expressions. It seemed to show the language’s struggle to recognize apparent equality. But what actually happens in that expression is this:

new Object() === new Object(); // false

Now it’s obvious they aren’t equal. You’re comparing two distinct objects you’ve just created. To expect contrary is the same as expecting 5 === 3 to return true. In both cases, they are different things.

Let’s do a sanity check. Would two variables referring to the same object be considered equal?

const my_object = {};
const other_thing = my_object;
my_object === other_thing; // true

In this case, only the first line has an expression that creates an object. On the second line, we make the other_thing variable refer to a just-created object. Two variables are now referring to the same object. Comparing them is just like comparing two equal numbers, isn’t it?

Why is this significant? Because it gives us a way to check if a variable refers to an object we’re looking for. And if we think about it in the context of “everything is an object,” that’s how numbers and strings work. When you compare two variables holding strings, the engine doesn’t have to check if each character in those strings is the same. It’s enough to compare if the variables refer to the same object. That is thanks to the most significant difference between regular objects and primitive values — immutability.

How To Bring Regular Objects Closer To Primitive Values

In JavaScript, Primitive values are immutable. You cannot change a single character in a string as well as you cannot make a number five to become six. If you use const to initialize a variable and put a primitive value in it, it’ll always stay the same. No one could change the value; it’s immutable. No one could reassign the variable; it was created with const.

Let’s look closely at how numbers work. You can get six out of five by incrementing it by one, but it doesn’t change anything about five.

const five = 5;
const six = 5 + 1;
five === 5; // true

Some might say that using let would change that. But look, it cannot change five:

const five = 5;
let result = 5;
result++;
result === 6; // true
five === 5; // true

A five is still a five. That is because ++ is just a shorthand for += 1. See the equals sign? What happened was I assigned a new value to the result variable, the value that I got from the result + 1 expression (which is what += 1 is a shorthand for). The const keyword prevents reassignment to a variable. In the example above, that’s what gives me a way to know that five always refers to a 5 object.

We might assume that the only way primitive values are changed in JavaScript is through the assignment, which means what we’re actually changing is what a variable refers to. So it’s variables that are changing, not values. Not primitive ones, at least. But how it works with objects instead?

After initializing an object, you can change its properties: delete them, add new ones, and reassign old ones. We are all familiar with doing that. But apart from that, it behaves the same as primitive values. In fact, if you get accustomed to a model where objects and primitive values are the same things, you’ll look differently at all sorts of problems in JavaScript.

You probably stumbled upon a question about how variables are passed to a function. People ask whether variables are passed by value or by reference. A common answer is primitive values are passed by value while objects are passed by reference. But with the mental model I’m forcing on you here, you might already know what I will say about that. Before that, let me show you how the question doesn’t make much sense in JavaScript. I will also reveal to you a sleight of hand that many articles and tutorials use.

When you pass variables as parameters of a function call, they get assigned to the function’s arguments. Arguments are local variables to a function’s scope and have no connection back to the original variables, which makes sense. If you pass an expression to a function, you have to put the result of it somewhere, don’t you?

Look at the following two functions. They do the same thing, pass a value through, but one is defined with a single parameter, the other with none. The second one demonstrates what is happening with the parameter we passed in.

function single(arg) {
return arg;
}

function none() {

// The first parameter is assigned to a variable `arg`.
// Notice the `let`; it will be significant later.
let arg = arguments[0];

return arg;
}

single(“hi”); // “hi”
none(5); // 5

You see that they both work the same. Keeping in mind how function arguments work, let’s try changing some values. We’ll have a function that changes its only argument and returns it. I also will create some variables that I’ll pass to the function one by one. Try to predict what would be printed in the console. (Answer is in the second sentence of the next paragraph.)

function reassign(arg) {
arg = “OMG”;
}

const unreassignable = “What”;
let reassignable = “is”;
let non_primitive = { val: “happening” };

reassign(unreassignable);
reassign(reassignable);
reassign(non_primitive);

console.log(unreassignable, reassignable, non_primitive.val, “😱”);

Did your guess has any “OMG” in it? It shouldn’t have, as the console will show “What is happening 😱.” No matter what gets passed to a function in JavaScript, reassigning changes only the argument variable. So, neither const nor let change anything here because the function doesn’t get the variable itself. But what happens if we try changing the properties of an argument?

I created another function that tries to change the val property of its argument. See if you can guess the message in the console this time.

function change_val_prop(arg) {
try {
arg.val = “OMG”;
} catch (ignore) {}
}

const a_string = “What”;
const a_number = 15;
const non_primitive = { val: “happening” };
const non_primitive_read_only = Object.freeze({ my_string: “here” });

change_val_prop(a_string);
change_val_prop(a_number);
change_val_prop(non_primitive);
change_val_prop(non_primitive_read_only);

console.log(
a_string.val,
a_number.val,
non_primitive.val,
non_primitive_read_only.val,
“😱”
);

Is there any “OMG” in your guess now? Great, the message is “undefined undefined OMG undefined 😱.” The only time the function could change the property is with a common object. What does it tell us? Is there any difference between how primitive values are passed and how objects are? Is it that passing frozen object suddenly changes it to pass-by-value? I think it’s more useful to treat them as equals.

Now about that sleight of hand I mentioned. Practically all the resources do that thing where they say that primitives and objects are passed differently, then immediately follow it with an example where they treat them differently. Look at function description in MDN. By the time of this writing, it described it like this (emphasis mine):

Arguments may be passed by value (in the case of primitive values) or by reference (in the case of objects). This means that if a function reassigns a primitive type parameter, the value won’t change outside the function. In the case of an object type parameter, if its properties are mutated, the change will impact outside of the function.

I just showed you the reassigning wouldn’t change the object either. You cannot change primitives’ properties because they are read-only, which is also the case for frozen objects. And most of the examples you’ll find do the same thing. They first state the difference between two values, then demonstrate it using different methods for each value.

I’m not trying to criticize, don’t get me wrong. It probably was done because it explains JavaScript quirks in a more familiar way. Just be aware that sometimes an explanation gives you a model of thinking about a problem. But the model is never completely true to the nature of a problem.

Looking at this issue from the perspective of primitives being just like frozen objects helps you to recognize what actually happens. Alternative tutorials become illogical. And now, having discovered this notion of a primitive object that no one could change, let us make them more friendly for the rest of your program.

Converting

Primitive values stand on their own; any program knows how to handle them. Objects could be anything. And even if you call them primitive, it’s not enough for them to suddenly become first-class citizens. To achieve some of that, we need to do some work.

You can define a way to convert objects into primitive values such as strings or numbers. For example, let’s create an object representing a rating from zero to five. We need to be able to work with numeric representation for comparison and sorting. We also need to be able to output it in text.

There are certain methods that you could define to describe your object’s representation. Remember [object Object]? It’s what you get when you try to turn your object into a string:

String({}); // “[object Object]”

Let’s change that.

String Representation

That output comes from the default toString method defined in the Object prototype. But you could overwrite it by defining it on your own object.

String({ toString: () => “hello there” }); // “hello there”

That’s what we will use for our rating objects. To make it convenient, let’s create a function that initializes and freezes such objects. It will also check if the value is within the zero to five range and return undefined otherwise.

function new_rating(value) {
const max = 5;

// That symbol forces textual representation (who needs emoji anyway 🙄).
const text_only = “ufe0e”;

const star = “⭑” + text_only;
const no_star = “⭐” + text_only;

if (
!Number.isSafeInteger(value) ||
(value < 0 || value > max)
) {
return undefined;
}

return Object.freeze({
value,
toString: () => star.repeat(value) + no_star.repeat(max – value)
});
}

Now let’s rate something. There is a pen I like. It’s pretty great, and I’d give it five stars.

const ratings = new WeakMap();
ratings.set(jetstream_pen, new_rating(5));

This WeakMap for ratings is how you could assign properties to objects without actually changing them. Now, whenever we want to have a rating, we can convert both of our objects to strings.

if (ratings.has(jetstream_pen)) {
console.log(`${jetstream_pen} ${ratings.get(jetstream_pen)}`);
// “Uni-Ball Jetstream 0.5 ⭑︎⭑︎⭑︎⭑︎⭑︎”
}

Wrapping both objects in string template literal is what I relied on here to trigger the toString method. Otherwise, you could just call the String function on them, as I did at the beginning of this section.

For Numberphiles

For numbers, there’s the valueOf method, which is called whenever there’s an attempt to convert to number comparisons or math operators (except for +). Let’s add it to our new_rating function:

function new_rating(value) {
// …

return Object.freeze({
value,
toValue: () => value,
toString: () => star.repeat(value) + no_star.repeat(max – value)
});
}

Now it might seem redundant to return the value property directly. But remember that no one but us knows that it’s there. Returning it from toValue is a universal way to get a numeric representation.

Let’s say we have our pen object again. And let’s say the rating is now its property (just to simplify the example). We can now filter out items with less than four stars:

articles.filter((item) => item.rating > 3);
// [ { name: “Uni-Ball Jetstream 0.5”, … } ]

Similarly, we can sort items by rating. We can do that using the Arrays’ sort method. You probably already have your favorite little sorting function that you’d like to use, like this one:

function sorter(first, second) {
return second.rating – first.rating;
}

const sorted_by_rating = array_of.sort(sorter);

Now, sorted_by_rating holds an array of the very best items.

Conclusion

I rarely looked at objects as something that could extend what could be expressed in JavaScript. With primitive objects, that’s what I’m trying to explore. There are still things we cannot add, like new operators or literal syntax, but still, with primitive objects, we could define new types of values.

In this first part of the Primitive Objects series, I tried to give an overview of how to make objects resemble some primitives properties. You freeze them to make them read-only. You also can define a representation in primitives, either number or string, to make it work with arithmetic operators or output them in text.

In the next parts coming up next week, I aim to give more examples of usage and comparison with other approaches I’ve encountered. You will see how to make it easier to create primitive objects and turn them into structures.

In this series, I’m trying to touch on JavaScript features that can be relied on. Even if not all of it makes sense, I hope that by looking at some of the examples I gave here, you’ll learn something useful that would make working with JavaScript less brittle without unnecessarily turning to additional tools.

10 Most Useful ChatGPT Tools So Far

Original Source: https://www.hongkiat.com/blog/chatgpt-tools/

The popularity of AI-powered GTP technology has been on the rise in recent years. It has transformed the way we interact with computers and have made it possible to achieve tasks faster and in more efficient and natural ways.

In this article, we will be showcasing 10 of the most powerful resources built on top of ChatGPT and GPT-3 based AI model, making it easier for you to take advantage of their full potential. So, if you’re looking to leverage AI technology in your life or work, this article is a must-read. Let’s begin.

1. ChatGPT Desktop

The ChatGPT Desktop is a multi-platform solution available on macOS, Linux, and Windows. You can use ChatGPT in your desktop and export your conversation history in PNG, PDF, and Markdown formats.

The app offers common shortcut keys and integrates with awesome-chatgpt-prompts for easy import of prompts which can be synced with one click and disabled if needed.

ChatGPT DesktopChatGPT Desktop
2. ChatGTP Everywhere

A Google Chrome extension for instant access to ChatGPT. With this extension, you can quickly gather information while using Google search. It also includes a sidebar that can be easily accessed with just one click, providing full access to the capabilities of ChatGPT’s language model anywhere the web.

ChatGTP EverywhereChatGTP Everywhere
3. ChatGPT for Gmail

A Chrome extension to help you deal with emails productively whether composing or answering the email. With the ability to complete the email subject, fix typos and provide an accessible button to activate the completion process, this extension makes email writing more efficient. Plus, the feature can be enabled or disabled at any time.

ChatGPT for GmailChatGPT for Gmail
4. AI Engine

A WordPress plugin that allows you to add a ChatGPT-style chatbot to your website with a simple shortcode. You can generate fresh content, doing translations, corrections and find suggestions in its AI Playground.

The plugin also provides quick title and excerpt suggestions, tracks your OpenAI usage with built-in statistics, and has an internal API for other plugins to tap and integrate into the plugin.

AI EngineAI Engine
5. AI Post Generator

Another AI-powered WordPress plugin that helps you with creating high-quality content for your website. The plugin is powered by OpenAI’s GPT-3 language model and supports multiple languages, automatically detecting the language of the title and generating content in the same language.

What makes it cool is that it can find high-quality images for your post that go with the topic or theme of the writing.

AI Post GeneratorAI Post Generator
6. GPT3 WordPress Post Generator

This script generates a WordPress post by utilizing the OpenAI GPT-3 API and the OpenAI Python library for API calls, and the WordPress XML-RPC library for post creation. You can control the length of content, topic, and even tone (e.g., funny, serious, formal) for the generated post.

GPT3 WordPress Post GeneratorGPT3 WordPress Post Generator
7. ChatGPT for Google

This browser extension integrates ChatGPT into popular search engines including Google, Baidu, Bing, DuckDuckGo, Brave, Yahoo, and Naver to display ChatGPT responses alongside the search results.

It features Markdown rendering, code highlighting, dark mode, copying to the clipboard, and language switching. All in all, this extension will enhance your search engine experience.

hatGPT for GooglehatGPT for Google
8. ChatGPT VSCode

A Visual Studio Code extension integrates ChatGPT API. It allows you to ask natural language questions and get answers from OpenAI’s ChatGPT directly in the editor. It provides a user-friendly input box in the sidebar to ask questions, a panel to view responses, and the ability to follow up with additional questions while maintaining conversation context.

Additionally, code snippets from the AI’s response can be inserted into the active editor with a click.

ChatGPT VSCodeChatGPT VSCode
9. ChatGPT macOS

A simple macOS application that integrates ChatGPT API into the menubar. It allows you to access it quickly with the Cmd+Shift+G shortcut from anywhere.

There’s no Windows version is currently available, but it can be run on Windows by cloning the repository, installing electron-forge, and running the build a command. In Windows, you can access it with the Ctrl+Shift+G shortcut.

ChatGPT macOSChatGPT macOS
10. ChatGPT for JetBrains

Aa plugin for JetBrains IDEs series that allows for integration with ChatGPT. It adds a section within the IDE where you can input prompts and view ChatGPT’s responses, providing a convenient assistant for code development.

ChatGPT for JetBrainsChatGPT for JetBrains

The post 10 Most Useful ChatGPT Tools So Far appeared first on Hongkiat.

Quick Tip: How to Disable Text Selection Highlighting in CSS

Original Source: https://1stwebdesigner.com/quick-tip-how-to-disable-text-selection-highlighting-in-css/

There are two main CSS properties that control text selection highlighting: user-select and -webkit-user-select. These properties are used to specify whether or not users are able to select text on the web page.

UNLIMITED DOWNLOADS: Email, admin, landing page & website templates
Starting at only $16.50 per month!

DOWNLOAD NOW

To disable text selection highlighting in CSS, you can set the value of the user-select property to none:

body {
-webkit-user-select: none; /* for Safari */
-moz-user-select: none; /* for Firefox */
-ms-user-select: none; /* for Internet Explorer */
user-select: none; /* for modern browsers */
}

In this example, the user-select property is applied to the body element, which means that text selection highlighting will be disabled for the entire page. If you want to disable text selection highlighting for a specific element, simply apply the property to that element instead of the body element.

It’s important to note that the -webkit-user-select and -moz-user-select properties are vendor-specific extensions, and are used to ensure compatibility with Safari and Firefox, respectively. The -ms-user-select property is used for compatibility with Internet Explorer. The standard user-select property should work in all modern browsers.

Nintendo Direct Live Blog: the biggest Switch news as it happens

Original Source: https://www.creativebloq.com/news/live/nintendo-direct-live-blog-2023

The 40-minute Nintendo Direct start time and how watch. Will we see Zelda, Metroid and Switch Pro?

Landing Your Dream Job with Lensa in Graphic Design

Original Source: https://designrfix.com/graphic-design/landing-your-dream-job-with-lensa

Landing your dream job in graphic design requires more than just a creative eye and technical skills. You need to have the right skills, an online presence, and a portfolio that demonstrates your abilities. In this article, we will discuss how to make yourself a more attractive candidate for a graphic design position by honing […]

Top 22 Python Books for Beginners and Advanced Coders

Original Source: https://www.sitepoint.com/best-python-books/?utm_source=rss

Top 22 Python Book for Beginners and Advanced Coders

All the books you need to get started with Python or improve your programming knowledge are included in this extensive list.

Continue reading
Top 22 Python Books for Beginners and Advanced Coders
on SitePoint.

How to Recover Deleted Videos on Windows 10/11

Original Source: https://www.hongkiat.com/blog/recover-deleted-videos-windows/

Accidentally deleting files or videos on your computer can be a very frustrating experience, especially if they are of importance. However, not all are lost.

The good news is that – there’s a high chance they are recoverable. And in this post, I will cover several methods to recover deleted videos with native Windows tools, as well as a 3rd-party file recovery tool.

First, Try This…

Whenever the delete command is executed, the file is moved from its current location to the Recycle Bin. That means, technically, the file is still recoverable until you clear the Recycle Bin.

To recover the deleted file, go to the respective folder where the file was, right-click and select “Undo Delete”.

This will bring the file back to its origin from Recycle Bin.

undo deleteundo delete
Recover with Window’s Backup and Restore

You can also restore deleted files from a backup created with the Window’s Backup and Restore feature.

Instructions:

Connect to the external storage device of your backup files.
In the search box, type “Control Panel” then hit Enter.
Search for the deleted files in the result and select “Backup and Restore”.
Select another backup to restore files from, select the location of your external storage device, and follow the on-screen instructions to restore your files.

For Windows 7 users, click here for the guide to recovering your deleted files.

Recover with Window’s File History

File History in Windows 10, and 11 automatically creates an additional copy of your files. However, for this to work, it must first be turned on.

Step 1: Turn on File History

Press Win + R to launch the Run command box.
Type in FileHistory and hit Enter.
Connect your Windows to an external storage device.
Click “Turn On” to enable File History.

Step 2: Recover deleted files using File History

Type restore files in the search box of the taskbar.
Select “Restore your files with File History”.
Look for the file you want to recover, then select “Restore”.

Recover Using a Third-party Software

If all else fails, then your last resort would be to recover with the help of a third-party application.

There are a plethora of data recovery tools out there, but in this post, I will focus on one of them – Tenorshare 4DDiG, and I will provide a walkthrough of how to get it done with the said application.

4DDiG app4DDiG app
4DDiG – In a Nutshell

Created by Tenorshare, 4DDiG is capable of recovering deleted files or files lost caused by local disk error or a computer crash.

Some of its other features include the following:

Supports recovery of various file types, including video, picture, audio, etc.
Supports recovery of deleted videos from internal and external drives, PC or Mac, USB flash drives, SD cards, and other devices.
Works on Windows 7,8,10 and 11.
No malicious pop-ups and ads.

Recovering Deleted Video Files with 4DDiG

Step 1:

Download and install 4DDiG on your Windows. Upon installation, the app will start recognizing the missing partition so that you can choose it as the target for the scan.

Note: You can also choose a specific target file type before scanning begins.

step 1step 1

Step 2:

When it detects that a video file has been erased, 4DDiG will instantly search the local disk and any lost partitions in the surrounding area for the file.

Note: You can suspend or cancel the search at any time.

step 2step 2

Step 3:

When the app identifies the video as having been erased, and you decide to recover it, just store it in a safe location on your local device.

step 3step 3
Bonus: Recover Deleted and Damaged Videos

Additionally, the 4DDiG app can also restore video files that have been damaged, broken, or otherwise rendered unplayable.

Go to Advanced Recovery on the sidebar.
Click “Click to add videos” and import the video you want to repair, then click “Repair”.
Finally, select the path you want the fixed video to be saved to, then click “Export”.

How to Prevent Video Loss on Your Computer?

Video loss is a common problem, especially among video content creators. While most of the time, it can be prevented by being more cautious about what you are deleting or removing from your system, errors caused by a hardware failure, on the other side, are harder to prevent.

Here are a few ways to keep video lost at bay:

1. Keep a Few Copies of Your Videos

It makes sense to keep an extra copy (or two) of the video file and all its assets. Keep a copy in your local computer if your hard drive’s capacity allows, then keep another copy in external hard drives or a Network-attached Storage (NAS).

2. Use Reliable Video Editing Software

Crashes could lead to loss of video, and it often happens during the editing process. Hence, it’s important to use reputable software when it comes to editing your videos. This will reduce the risk of loss and corruption.

3. Save Working File Regularly

Not all video editing software comes with an auto-save feature. Make it a habit to manually save the working file as regularly as you can to minimize any loss shall a software crash happen.

Summary

So the main takeaway from this is – prevention is definitely better than cure. Making sure your system’s health is in good condition and keeping a good habit of saving the working file regularly will drastically reduce the list of video loss.

If you’ve accidentally deleted a video file, do check inside the Recycle Bin first. If you are lucky, you might still find it there. But if it’s not, try taking advantage of windows’ System Restore or File History.

But if all else fails, invest in a 3rd-party file recovery app for peace of mind.

The post How to Recover Deleted Videos on Windows 10/11 appeared first on Hongkiat.