IAMCP-US https://www.iamcp-us.org Fri, 27 Aug 2021 07:35:15 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.3 https://www.iamcp-us.org/wp-content/uploads/2021/07/cropped-code-blocks-icon-32x32.png IAMCP-US https://www.iamcp-us.org 32 32 11 of the Best Computer Technology and Apps for Motorcyclists in 2021 https://www.iamcp-us.org/11-of-the-best-computer-technology-and-apps-for-motorcyclists-in-2021/ https://www.iamcp-us.org/11-of-the-best-computer-technology-and-apps-for-motorcyclists-in-2021/#respond Fri, 27 Aug 2021 07:35:13 +0000 https://www.iamcp-us.org/?p=661 It is no secret to anyone that we find ourselves at odds in which we could not imagine life without our mobile phones. Technological tools and applications are installed and used daily, we use them for everything and our cell …

The post 11 of the Best Computer Technology and Apps for Motorcyclists in 2021 appeared first on IAMCP-US.

]]>
It is no secret to anyone that we find ourselves at odds in which we could not imagine life without our mobile phones. Technological tools and applications are installed and used daily, we use them for everything and our cell phone accompanies us everywhere, even when we are riding on our motorcycle.

If you are a motorcyclist, then there is no doubt that the excitement of riding, the gust of wind, and the anticipation of a short adrenaline trip next week will keep you away.

Along with the helmet, boots, or jacket with protections, the mobile cannot be missing as part of the basic equipment on your trips on two wheels. This is the selection of free applications that we consider worthy of occupying space in the memory of your Smartphone.

Although mobile devices may be the last thing you want to worry about during your Easter weekend trip, it has become a must-have for those who want to plan their trips, track various expenses, and make contributions. A community of like-minded motorcyclists.

In the same way, these applications will be of great help for the day-to-day of all motorcyclists to make moving within the city more pleasant onboard your adventure companion.

Some newer models of motorcycles have GPS navigators installed on their dashboard but if you bought used and older models from ZeCycles.com, you still could enjoy these computer and mobile phone applications, making your life easier while riding.

Here is a list of 11 applications that cannot be missing from every biker’s smartphone.

  1. Direct Line App

Direct Line App: it is the Direct Line application with utilities for all drivers. Its functionalities include: the location of the motorcycle on the map once parked; a comprehensive guide to what to do in the event of an accident, as well as a BAC calculator. Customers have access to their insurance and services, such as requesting travel assistance, a replacement vehicle, or tracking parts. Free for iOS and Android.

  1. Rain Alarm

Rain Alarm: It is a weather application that warns of any type of precipitation that is approaching and may interfere with our trip. The data is presented reflected on a map (available for Spain, a large part of Europe, and the US). Free for iOS and Android.

  1. iCoyote

iCoyote: The “Coyote Community” reports everything that happens on the road so that you increase safety on your motorcycle. From detentions and accidents in real-time so that you can plan alternative routes, to information on fixed / mobile radars and controls. It offers the possibility of reporting by voice. Free for iOS and Android.

  1. Waze

Waze has the title of the world’s largest transportation and navigation application. This companion program is touted by various motorcycle blogs as one of the best real-time browsers that can help you get rid of the morning rush. In addition, it was developed by the company to provide drivers with reports and routes used by car and motorcycle drivers. With such a large ecosystem and accurate data from various sources, motorcyclists will certainly benefit from Waze like any other traveler.

  1. Sygic

Sygic is a really awesome GPS navigation app. If you are wondering why we shouldn’t use Google Maps for this purpose, let me tell you; There is a great aspect of this application that beats Google Maps and that is that it does not need a connection to run. Another added part of Sygic is that it doesn’t drain your phone’s battery as fast as Google Maps does. And how to finish talking to you. This application is used by more than 200 million drivers in the world.

  1. WeRide

WeRide is the best social network for motorcyclists. Provide each driver with a new way to connect with friends and find new friends. WeRide is full of useful features, allowing you to share your passion with your existing motorcycle friends. You can also invite others to join your circles and make new friends and contacts. This application provides GPS real-time location tracking. When you leave, you will see that other passengers are also using this app, and their location will be displayed on the map, so you can easily find them.

  1. Guardian angel

Guardian Angel is an application that will detect any possible accident you may have suffered and will automatically send your exact location to those users of your choice, to the relevant emergency response teams, and will keep up to three of your loved ones informed. The sent alert will be received by a professional response team who will then dispatch mobile units to your location. Your situation could be one of four instances; Safety, Medical, Fire, and Non-Critical.

  1. Drivvo

The application allows you to easily manage your fuel log, fuel consumption, and motorcycle services. Your records will allow you to keep track of what you spend on your motorcycle. There is also a collaborative feature where it allows you to check fuel prices at nearby stations.

  1. ParkMe Parking

ParkMe Parking: With this application, you will have three utilities in one, find parking, save it to know where you have left the motorcycle, and use the map to get to it. Free for iOS and Android.

  1. Wikiloc

Wikiloc: This application is very interesting since it allows you to record your motorcycle routes on a map and take photos throughout your trip. Discover itineraries that other users have uploaded and download their routes on your GPS to navigate. Free for iOS and Android.

  1. Monster Energy Supercross

Monster Energy Supercross: As good Gamers, we could not miss a motorcycle application for our entertainment on the list. Compete with your pilot in different game modes: a single-player Career mode in which you will alternate between four different types of races, a multiplayer mode to compete against other real players, or tournaments from around the world in real-time during the championship weekends. Live the dream of becoming a Monster Energy Supercross superstar

The post 11 of the Best Computer Technology and Apps for Motorcyclists in 2021 appeared first on IAMCP-US.

]]>
https://www.iamcp-us.org/11-of-the-best-computer-technology-and-apps-for-motorcyclists-in-2021/feed/ 0
Recycling of computers and IT equipment: how does it work? https://www.iamcp-us.org/recycling-of-computers-and-it-equipment-how-does-it-work/ https://www.iamcp-us.org/recycling-of-computers-and-it-equipment-how-does-it-work/#respond Fri, 27 Aug 2021 07:31:49 +0000 https://www.iamcp-us.org/?p=654 Do you know how to get rid of an old computer? Millions of computers and other electronic equipment become obsolete every year, yet many people do not know how to properly throw away a computer. Don’t just throw them in …

The post Recycling of computers and IT equipment: how does it work? appeared first on IAMCP-US.

]]>
Do you know how to get rid of an old computer? Millions of computers and other electronic equipment become obsolete every year, yet many people do not know how to properly throw away a computer. Don’t just throw them in the trash, there are better ways to get rid of them. You can recycle old computers, which helps reduce pollution and reduce energy consumption. You can also reuse or even donate old computers if they still work.

Electronic devices contain valuable resources, such as gold, palladium, copper, and other rare metals. Computers also contain copper, mercury, cadmium, materials that can be toxic if they come into contact with groundwater or are incinerated. Generally speaking, it is always better to reduce the amount of waste to dispose.

Before you start, do you really need to get rid of it? Check out our guide to help you determine whether you need to upgrade or replace your computer. Often times an upgrade will speed up and modernize your system and surprise you. But with aging PCs, they often just have to be reused, donated, or replaced and recycled.

The law on recycling computers and computer equipment is very strict. No way to drop them off anywhere, or give them to anyone.

Computer recycling: strict regulations

European directives have imposed strict regulations on the recycling of computers and the recycling of WEEE (Waste from Electrical and Electronic Equipment) more generally.

Recycle computers to protect the environment

It is absolutely forbidden to throw a computer in the trash. Indeed, this material contains dangerous and polluting substances which must not be found in nature. It also contains rare components that can be recovered and reused. Recycling computers and IT equipment are therefore necessary.

The principle of “one for one”

The collection and recycling of waste electrical and electronic equipment (D3E), of which computers and IT equipment are part, are the responsibility of the producers (manufacturers, importers, or resellers). For this, they must join an eco-organization such as Ecologic or eco-system or organize the collection themselves. Since 2014, according to the “one for one” principle, the legislation obliges the distributor to take back the computer equipment when the customer buys an equivalent product in his store.

WEEE tax or eco-contribution

Recycling is paid for by the end-user through a tax, the famous eco-contribution, which is systematically added in a transparent manner to the selling price of IT equipment. This tax is paid in full to the body responsible for the collection and recycling of WEEE.

Devices with and without a screen

Recycling of printers, laptops, hard drives, processors, motherboards, mice, keyboards, USB keys, scanners, headsets, GPS…. Almost all of this equipment can be recycled. However, not all of these devices are recycled in the same way. When you decide to get rid of computer equipment, it is, therefore, necessary to separate the equipment “with screen” from those “without screen”.

Recycling of computer equipment without a screen

Put on one side, all that is said to be “screenless”, that is to say, devices that run on battery, battery, or mains, such as printers, central units, internet boxes, external hard drives, helmets …

Attention small trap with the GPS which falls under the category “without a screen” because this one is less than 7 inches. All these devices go to one of the 17 processing centers in France which will manage small electrical and electronic devices. The famous WEEE or D3E.

Computer recycling with screen

You will understand all devices with a screen of more than 7 inches (i.e. a diagonal of 18 cm) go into another recycling and depollution route. You will therefore not put them in the same bin.

Computer and hardware recycling: who to give them to?

You can’t put your computers anywhere when you’ve decided to dispose of them. And above all, we cannot drop them off at the recycling center! Specialized organizations will take care of their collection and recycling.

Computer recycling for an individual

Before you throw away your devices, sort them. Remove the batteries and put them in a separate recycling bin. Be sure to separate equipment with a screen from those without a screen which, as we have just seen, do not recycle in the same way.

Drop off your computer equipment at collection points

The first rule that may surprise you: do not put your computers on the sidewalks or in bulky items. Did you think you were doing well? Well no! If your computer equipment arrives in bulky items it will not be cleaned up or recycled.

Where to drop them off then? There are 12,000 collection points throughout France (waste reception centers or solidarity networks), and in the US there are almost everywhere. There is bound to be one in your city. By depositing them at these specific collection points, you have the guarantee that they will be treated in accordance with European WEEE recycling standards.

If you are thinking of getting a new computer, stores are obligated to take back your old machine free of charge on the condition that you purchase a new one.

Donate to associations or resource centers

Your computer is still good for use. Consider donating it to associations, schools, institutions, resource centers. You will make people happy! NGOs or reintegration companies can take care of restoring them to working order or repackaging them in order to give them away or sell them at a low price.

Recycling of business IT equipment

You are a company and you need to renew your computer equipment which is starting to date. But what to do with your old computers piling up in a room? There are many specialist providers in your area who can get rid of it. For free or for a fee, they will remove and recycle your old computers. Some may also buy your PCs, laptops, central units, flat screens, or tablets from you if they are still in working order in order to promote them on the second-hand market.

The post Recycling of computers and IT equipment: how does it work? appeared first on IAMCP-US.

]]>
https://www.iamcp-us.org/recycling-of-computers-and-it-equipment-how-does-it-work/feed/ 0
Hello World! in C # https://www.iamcp-us.org/hello-world-in-c/ https://www.iamcp-us.org/hello-world-in-c/#respond Thu, 01 Jul 2021 14:52:45 +0000 https://www.iamcp-us.org/?p=554 If you’ve ever studied programming languages, you probably know that it all starts with the “Hello, world!” Who are we to break this tradition? Launch Visual Studio Community (presented in the previous thread) and select File -> New -> Project. …

The post Hello World! in C # appeared first on IAMCP-US.

]]>
If you’ve ever studied programming languages, you probably know that it all starts with the “Hello, world!” Who are we to break this tradition? Launch Visual Studio Community (presented in the previous thread) and select File -> New -> Project. In the window that appears, select Console Application (.NET framework). This is the most common type of application on Windows, but ideal for language learning. Once you click OK, Visual Studio will create a new project, including the Program.cs file, which contains “all the juice” of the program and looks something like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
    static void Main(string[] args)
    {
    }
    }
}

In fact, these lines don’t really do much, or at least they seem to. Try running the program by pressing F5 on your keyboard. This will force Visual Studio to compile and run your code, but you will most likely see a black window start and close. This is due to the fact that the program does nothing yet. In the next topic we will go through the lines of code and understand what they are for, but for now we just want to see the output of the program, so let’s pretend we know everything about C # and add a couple of lines to see the output of the code. In the last couple {} add the following lines:

Console.WriteLine("Hello, world!");
Console.ReadLine();

Your first program should now look like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
    static void Main(string[] args)
    {
        Console.WriteLine("Hello, world!");
        Console.ReadLine();
    }
    }
}

Press F5 again and run the program. You will see a black window, which now does not close immediately after opening. You will also see your “Hello” to the world. Okay, we’ve added two lines to the code, but what do they do? One of the great things about C # and the .NET framework is that most of the code is legible, even to the untrained eye. This is what this example shows.

The first line of code uses the console to output a line of text, and the second reads the text from the console. Reads? What for? This is actually a little trick, because without it, the program would instantly close the output window before you saw anything.

The post Hello World! in C # appeared first on IAMCP-US.

]]>
https://www.iamcp-us.org/hello-world-in-c/feed/ 0
Filtering and sorting in JS using the MixItUp library https://www.iamcp-us.org/filtering-and-sorting-in-js-using-the-mixitup-library/ https://www.iamcp-us.org/filtering-and-sorting-in-js-using-the-mixitup-library/#respond Thu, 01 Jul 2021 13:44:16 +0000 https://www.iamcp-us.org/?p=547 MixItUp is a high performance, no dependency library for animated DOM manipulation that gives you the ability to filter, sort, add and remove DOM elements with beautiful animation. MixItUp blends beautifully with your existing HTML and CSS, making it a …

The post Filtering and sorting in JS using the MixItUp library appeared first on IAMCP-US.

]]>
MixItUp is a high performance, no dependency library for animated DOM manipulation that gives you the ability to filter, sort, add and remove DOM elements with beautiful animation.

MixItUp blends beautifully with your existing HTML and CSS, making it a great choice for responsive layouts. The library is compatible with inline-flow, percentages, media queries, flexbox and more.

Beginning of work
Most often, MixItUp is applied to container or target elements, which can be a portfolio of projects, a list of blog posts, a selection of products, or any kind of user interface where filtering and / or sorting would be useful.

Assembling the container
By default, MixItUp will ask the container for a target that matches the .mix selector.

<div class="container">
    <div class="mix category-a" data-order="1"></div>
    <div class="mix category-b" data-order="2"></div>
    <div class="mix category-b category-c" data-order="3"></div>
    <div class="mix category-a category-d" data-order="4"></div>
</div>

Targets can be filtered using any valid selector such as .category-a and sorted using optional custom data attributes such as data-order.

Control

One way of filtering and sorting happens when the controls are clicked. You can use any clickable element as a control, but is recommended for convenience. Filter controls are requested based on the presence of a data filter attribute whose value must be all, none, or a valid selector string such as .Category.

<button type="button" data-filter="all">All</button>
<button type="button" data-filter=".category-a">Category A</button>
<button type="button" data-filter=".category-b">Category B</button>
<button type="button" data-filter=".category-c">Category C</button>

Sort control

Sort controls are requested based on the presence of the data-sort attribute, whose value takes the form of a sort string consisting of the name of the attribute to sort, followed by an optional colon-separated sort order, for example, ‘order’, ‘order: asc’, ‘order : desc ‘.

<button type="button" data-sort="order:asc">Ascending</button>
<button type="button" data-sort="order:descending">Descending</button>
<button type="button" data-sort="random">Random</button>

The values ​​default and random are also valid, with default referring to the original order of the target elements in the DOM at the time the mixer is instantiated.

Styling a container

While MixItUp can be added on top of any existing CSS layout, it is recommended that you use flexbox-based styles for floats and legacy grid frames when working with grid designs for a number of reasons.

Download MixItUp

First, download the MixItUp JavaScript library using the preferred method for your project. The easiest way to load MixItUp into your project is to include it through the </script> tag before the closing </body> tag on your page. You can download the script on the official website. In the folder you will find examples of using the MixItUp library with different settings.

   ...
        <script src="/path/to/mixitup.min.js"></script>
    </body>
</html>

With this method, the MixItUp library function will be available through the global variable mixitup.

Import module

If you are building a JavaScript modular project using Webpack, Browserify, or RequireJS, MixItUp can be installed using a package manager of your choice (e.g. npm, jspm, yarn) and then imported into any of your project’s modules.

npm install mixitup --save

// ES2015
import mixitup from 'mixitup';

// CommonJS
var mixitup = require('mixitup');

// AMD
require(['mixitup'], function(mixitup) {
});

Creating a mixer

With the mixitup () library function available, you can now create a mixer in your container to enable the MixItUp function. Call the library function, passing in a selector string or a reference to a container element as the first parameter, and a newly created mixer instance will be returned.

Creating a mixer using a selector string:

var mixer = mixitup('.container');

Creating a mixer with a link to an item:

var mixer = mixitup(containerEl);

Your mixer is now ready to interact through the controls (see above) or API (see the mixer API methods in the documentation). Click the control or call an API method to verify that everything is working correctly.

Configuration

If you want to customize the functionality of your mixer, an optional configuration object can be passed as the second parameter to the mixitup function. If no configuration object is passed, the default settings will be used.

Passing a config object:

var mixer = mixitup(containerEl, {
    selectors: {
        target: '.blog-item'
    },
    animation: {
        duration: 300
    }
});

API usage

If you want to interact with your mixer through its API, the mixer reference returned by the library function can be used to call API methods.

API method call:

var mixer = mixitup(containerEl);
mixer.filter('.category-a');

You can also use the new MixItUp dataset API. The dataset is intended for use in API-based JavaScript applications and can be used in place of DOM-based methods like .filter (), .sort (), .insert (), etc. When used, insertion, deletion, sorting and pagination can be achieved solely through changes to your data model, without the need to interact with or directly query the DOM.

The post Filtering and sorting in JS using the MixItUp library appeared first on IAMCP-US.

]]>
https://www.iamcp-us.org/filtering-and-sorting-in-js-using-the-mixitup-library/feed/ 0
JQuery connection https://www.iamcp-us.org/jquery-connection/ https://www.iamcp-us.org/jquery-connection/#respond Thu, 01 Jul 2021 13:25:59 +0000 https://www.iamcp-us.org/?p=544 jQuery is a fast, small and feature-rich JavaScript library included in a single .js file. It is by far the most popular JavaScript library. JQuery makes the web developer’s life easier. The library provides many built-in functions with which you …

The post JQuery connection appeared first on IAMCP-US.

]]>
jQuery is a fast, small and feature-rich JavaScript library included in a single .js file. It is by far the most popular JavaScript library.

JQuery makes the web developer’s life easier. The library provides many built-in functions with which you can easily and quickly perform various tasks with less code.

Important features of jQuery

DOM selection: jQuery provides selectors to retrieve a DOM element based on various criteria such as tag name, id, css class name, attribute name, value, nth child in the hierarchy, etc.

DOM manipulation: You can manipulate DOM elements using various built-in jQuery functions. For example, adding or removing elements, changing HTML content, CSS class, etc.

Special Effects: You can apply special effects to DOM elements, such as showing or hiding elements, fading in or out, sliding effect, animations, and more.

Events: The jQuery library includes functions that are equivalent to DOM events such as press, dblclick, mouseenter, mouse release, blur, keyup, keydown, etc. These features automatically resolve browser issues.

Ajax: jQuery also includes easy-to-use AJAX functions to load data from servers without reloading the entire page.

Cross-browser support: The jQuery library handles cross-browser issues automatically, so the user doesn’t need to worry about it. jQuery supports IE 6.0+, FF 2.0+, Safari 3.0+, Chrome, and Opera 9.0+.

JQuery benefits

Easy to Learn: jQuery is easy to learn because it supports the same JavaScript style coding.

Write less, do more: jQuery provides a rich set of features that improve developer productivity by writing less readable code.

Excellent API documentation: jQuery provides excellent online API documentation.

Cross-browser support: jQuery provides excellent cross-browser support without writing additional code.

Unobtrusive: jQuery is unobtrusive, which allows you to separate concerns by separating HTML and jQuery code.

JQuery Versions

There are currently three versions of jQuery: 1.x, 2.x, and 3.x. The only difference in the second version is that it no longer supports old browsers, such as Internet Explorer below version 8. This made it possible to reduce the size of the library file and speed up its work. The third version received even more acceleration, new methods and fixes.

JQuery is also used in a compressed (.min) and non-compressed version. You can use the uncompressed version of the library during development. In a compressed version, the code is minimized and it is almost impossible to make any changes to it. Therefore, the compressed version is used already on the working project for more optimal work, since the library in this version takes up much less space and is processed faster.

JQuery connection

There are 2 ways to connect jQuery to your project: local and using CDN. With the local method, the library is connected as a regular .js file that is located on your server. When connecting from a CDN, the library connects from a remote server, for example, from a Google CDN. Let’s take a closer look at each method.

Connecting jQuery locally

  1. Download the jQuery library js file from the official page. Just right-click on the download link and select “Save Link As” from the pop-up menu.
  1. Then save the download file in your site directory. For example, I just save it in the js folder of my project along with the rest of the js scripts.
  2. Now you need to include the previously downloaded library file in your page. Place the following code between the and tags:
<script type="text/javascript" src="jquery-3.5.0.min.js"></script>

You should end up with something like this:

<!doctype html>
<html>
<head>
    <title>jQuery</title>
    <script src="jquery-3.5.0.min.js"></script>
</head>
<body>
    <h1>Conaction jQuery</h1>
</body>
</html>

Connecting jQuery with CDN

Connecting jQuery hosted on a CDN is similar to a local one, except that the library file will not be on your server, but on a remote one. Aside from this detail, you simply add jQuery to your page like any other external JavaScript file.

One big benefit of using Google hosted jQuery: Many users have already downloaded jQuery from the Google CDN when visiting another website. As a result, it will be loaded from the cache when you visit your site, which leads to faster loading. In addition, Google CDN will make sure that after a user requests a file from him, it is sent from the server closest to them, which also leads to faster downloads.

The most popular CDNs are Google CDN and jQuery CDN. We will consider connecting from Google CDN, but connecting from other servers is the same and you can choose any option you like.

The post JQuery connection appeared first on IAMCP-US.

]]>
https://www.iamcp-us.org/jquery-connection/feed/ 0
PHP Regular Expressions: preg_match, preg_split, preg_replace https://www.iamcp-us.org/php-regular-expressions-preg_match-preg_split-preg_replace/ https://www.iamcp-us.org/php-regular-expressions-preg_match-preg_split-preg_replace/#respond Thu, 01 Jul 2021 12:19:19 +0000 https://www.iamcp-us.org/?p=521 Regular expressions are a powerful pattern matching algorithm that can be performed in a single expression. Regular expressions use arithmetic operators such as (+, -, ^) to create complex expressions. Regular expressions help you perform tasks such as validating email …

The post PHP Regular Expressions: preg_match, preg_split, preg_replace appeared first on IAMCP-US.

]]>
Regular expressions are a powerful pattern matching algorithm that can be performed in a single expression. Regular expressions use arithmetic operators such as (+, -, ^) to create complex expressions. Regular expressions help you perform tasks such as validating email addresses, IP addresses, and more.

Why use regular expressions

  • Regular expressions make it easy to identify patterns in string data by calling a single function. This saves us coding time.
  • When validating user input such as email address, domain names, phone numbers, IP addresses.
  • Highlight keywords in search results.
  • When creating a custom HTML template. Regular expressions can be used to identify template tags and replace them with actual data.

PHP Regular Expressions

PHP has built-in functions that allow us to work with regular expressions. Let’s now take a look at the commonly used regular expression functions in PHP.

preg_match – This function is used to match against a pattern in a string. It returns true if a match is found and false if no match is found.
preg_split – This function is used to match against a pattern in a string and then splits the results into a numeric array.
< code> preg_replace – This function is used to match against a string pattern and then replace the match with the specified text.
The following is the syntax for a regular expression function such as preg_match , preg_split or preg_replace :

<?php
function_name('/pattern/',subject);
?>

“Function_name (…)” is either preg_match, preg_split, or preg_replace.
“/ … /” The forward slash marks the beginning and end of our regular expression.
“/ Pattern /” is the pattern we need.
“Subject” is the text string to match against.

Let’s now take a look at practical examples that implement the aforementioned regex functions in PHP.

PHP preg_match

In the first example, the preg_match function is used to simply pattern match the word it-blog in a given URL.

The code below shows the implementation for the above example.

<?php
$my_url = "www.iamcp-us.org";
if (preg_match("/iamcp-us.org/", $my_url))
{
    echo "String $my_url contains iamcp-us.org";
}
else
{
    echo "String $my_url not contain iamcp-us.org";
}
?>

PHP preg_split

Let’s now take a look at another example that uses the preg_split function.

We will take a string phrase and create an array from it using the pattern: element / space.

The text string to use in this example is “I love regular expressions.”

The code below illustrates the implementation of the above example.

<?php

$my_text="Regular expressions";

$my_array  = preg_split("/ /", $my_text);

print_r($my_array );

?>

PHP preg_replace

Let’s now take a look at the preg_replace function, which performs pattern matching and then replaces the pattern with something else.

The code below looks for the word it-blog in the string.

It replaces the word “iamcp-us” with the word “iamcp-us” surrounded by CSS code that highlights the background color.

<?php

$text = "Programming. iamcp-us.org";

$text = preg_replace("/iamcp-us.org/", '<span style="background:yellow">it-blog.ru</span>', $text);

echo $text;

?>

The post PHP Regular Expressions: preg_match, preg_split, preg_replace appeared first on IAMCP-US.

]]>
https://www.iamcp-us.org/php-regular-expressions-preg_match-preg_split-preg_replace/feed/ 0
Python: a simple neural network https://www.iamcp-us.org/python-a-simple-neural-network/ https://www.iamcp-us.org/python-a-simple-neural-network/#respond Wed, 01 Jul 2020 09:58:23 +0000 https://www.iamcp-us.org/?p=22 Installing numpy For the application to work, we need to install the numpy library – this is a Python library for working with arrays and various mathematical functions. This can be done as usual through the command line by calling …

The post Python: a simple neural network appeared first on IAMCP-US.

]]>
Installing numpy

For the application to work, we need to install the numpy library – this is a Python library for working with arrays and various mathematical functions. This can be done as usual through the command line by calling the pip package installer, which is included in the standard Python distribution. On the command line, enter pip install numpy:

Creation of a neural network

In the cgi-bin folder, create a new main.py file and add the following code to it:

#!/usr/bin/env python3
import numpy as np

vodka = 0.0
rain = 1.0
friend = 0.0

def activation_function(x):
    if x >= 0.5:
        return 1
    else:
        return 0

def predict(vodka, rain, friend):
    inputs = np.array([vodka, rain, friend])
    weights_input_to_hiden_1 = [0.25, 0.25, 0]
    weights_input_to_hiden_2 = [0.5, -0.4, 0.9]
    weights_input_to_hiden = np.array([weights_input_to_hiden_1, weights_input_to_hiden_2])

    weights_hiden_to_output = np.array([-1, 1])

    hiden_input = np.dot(weights_input_to_hiden, inputs)
    print("hiden_input: " + str(hiden_input))

    hiden_output = np.array([activation_function(x) for x in hiden_input])
    print("hiden_output: " + str(hiden_output))

    output = np.dot(weights_hiden_to_output, hiden_output)
    print("output: " + str(output))
    return activation_function(output) == 1

print("Content-type: text/html")
print()
print("result: " + str(predict(vodka, rain, friend)))

The post Python: a simple neural network appeared first on IAMCP-US.

]]>
https://www.iamcp-us.org/python-a-simple-neural-network/feed/ 0
Artificial Intelligence Voice Bot in Python https://www.iamcp-us.org/artificial-intelligence-voice-bot-in-python/ https://www.iamcp-us.org/artificial-intelligence-voice-bot-in-python/#respond Sat, 01 Feb 2020 09:19:35 +0000 https://www.iamcp-us.org/?p=8 In this tutorial, we will analyze the creation of a voice bot using neural network technology in Python. The bot can recognize a human voice in real time from your device, such as a laptop microphone, and speak out conscious …

The post Artificial Intelligence Voice Bot in Python appeared first on IAMCP-US.

]]>
In this tutorial, we will analyze the creation of a voice bot using neural network technology in Python. The bot can recognize a human voice in real time from your device, such as a laptop microphone, and speak out conscious responses that are processed by the neural network.

The bot consists of two main parts: this is the dictionary processing part and the voice assistant part.

You can conduct all the development of writing a bot in the PyCharm IDE, you can download it from the JetBrains official website.

All required libraries can be installed using PyPI right in the PyCharm console. You can find the installation commands on the official website in the section of the required library.

Dataset

A data set is a set of data for analysis. In our case, it will be a text file containing lines in the form of a question / answer.

All lines of text are iterated over using the for function, while all unnecessary characters are removed from the text by the mask found in the alphabet variable. Each string value is separately entered into the dataset array.

After processing the text, all its values ​​are converted into vectors using the Scikit-learn machine learning library. This example uses the CountVectorizer () function. Further, all vectors are assigned a class using the LogisticRegression () classifier.

When a message comes from the user, it is also converted into a vector, and then the neural network tries to find a similar vector in the dataset corresponding to a certain question, when the vector is found, we will receive an answer.

Voice Assistant


For voice recognition and sounding the bot’s responses, the SpeechRecognition library is used. The system waits in an endless loop when a question comes, in our case a voice from a microphone, after which it converts it into text and sends it for processing to the neural network. After receiving a text response, it is converted into speech, the recording is saved in the project folder and deleted after playback. It’s that simple! For convenience, all messages are duplicated in text to the console.

With the default settings, the response time was quite long, sometimes it was necessary to wait for 15-30 seconds. In addition, the question was received from the slightest noise. The following settings helped:

voice_recognizer.dynamic_energy_threshold = False
 voice_recognizer.energy_threshold = 1000
 voice_recognizer.pause_threshold = 0.5

And timeout = None, phrase_time_limit = 2 in the listen () function

After that, the bot began to respond with minimal delay.

Other values may work for you. You can see the description of these and other settings on the same PyPI website in the SpeechRecognition library section. But for some reason I didn’t find the phrase_time_limit setting there, I stumbled upon it by accident on Stack Overflow.

Data set text


This is a small sample of text. Of course, there should be much more questions and answers.

Hi Hi
how are you \ everything is fine
how are you \ thanks great
who are you \ I am a bot
what are you doing / talking to you

Python code

import speech_recognition as sr
from gtts import gTTS
import playsound
import os
import random
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.linear_model import LogisticRegression
# Vocabulary
def clean_str(r):
    r = r.lower()
    r = [c for c in r if c in alphabet]
    return ''.join(r)
alphabet = ' 777abc'
with open('dialogues.txt', encoding='utf-8') as f:
    content = f.read()
blocks = content.split('\n')
dataset = []
for block in blocks:
    replicas = block.split('\\')[:2]
    if len(replicas) == 2:
        pair = [clean_str(replicas[0]), clean_str(replicas[1])]
        if pair[0] and pair[1]:
            dataset.append(pair)
X_text = []
y = []
for question, answer in dataset[:10000]:
    X_text.append(question)
    y += [answer]
vectorizer = CountVectorizer()
X = vectorizer.fit_transform(X_text)
clf = LogisticRegression()
clf.fit(X, y)
def get_generative_replica(text):
    text_vector = vectorizer.transform([text]).toarray()[0]
    question = clf.predict([text_vector])[0]
    return question
# Voice Assistant
def listen():
    voice_recognizer = sr.Recognizer()
    voice_recognizer.dynamic_energy_threshold = False
    voice_recognizer.energy_threshold = 1000
    voice_recognizer.pause_threshold = 0.5
    with sr.Microphone() as source:
        print("speak 🎤")
        audio = voice_recognizer.listen(source, timeout = None, phrase_time_limit = 2)
    try:
        voice_text = voice_recognizer.recognize_google(audio, language="en")
        print(f"You said: {voice_text}")
        return voice_text
    except sr.UnknownValueError:
        return "Recognition error"
    except sr.RequestError:
        return "Connection error"
def say(text):
    voice = gTTS(text, lang="ru")
    unique_file = "audio_" + str(random.randint(0, 10000)) + ".mp3"
    voice.save(unique_file)
    playsound.playsound(unique_file)
    os.remove(unique_file)
    print(f"Бот:  {text}")
def handle_command(command):
    command = command.lower()
    reply = get_generative_replica(command)
    say(reply)
def stop():
    say("Пока")
def start():
    print(f"Bot launch...")
    while True:
        command = listen()
        handle_command(command)
try:
    start()
except KeyboardInterrupt:
    stop()

The post Artificial Intelligence Voice Bot in Python appeared first on IAMCP-US.

]]>
https://www.iamcp-us.org/artificial-intelligence-voice-bot-in-python/feed/ 0
Remove value from array in PHP https://www.iamcp-us.org/remove-value-from-array-in-php/ Mon, 01 Apr 2019 10:17:54 +0000 https://www.iamcp-us.org/?p=31 Deleting a value from an array by key in PHP is quite a simple task, but when it is necessary to delete an element of an array exactly by value, then there are slight difficulties. It seems to be a …

The post Remove value from array in PHP appeared first on IAMCP-US.

]]>
Deleting a value from an array by key in PHP is quite a simple task, but when it is necessary to delete an element of an array exactly by value, then there are slight difficulties. It seems to be a trivial task, but you have to use a little trick. In this article, we will look at how to delete an array element in PHP both by value and by key.

Remove value from array by key

Everything is very simple here. We need the PHP function unset (), which removes variables. With its help, you can also delete an array element by key. In the example below, we are removing the element with the key name from the $ array:

<?
$array = array('name' => 'Иван', 'lastname' => 'Иванов', 'site' => 'https://it-blog.ru');
unset($array['name']);
?>

As you can see, everything is quite simple, but how to remove an element from an array by its value, because the unset () function can find an element only by its key. You will learn more about this later.

Remove array element by value

To remove an element of an array by value, we will also use the unset () function, which removes elements by key, but first we will find an element by value. Another function array_search () will help us with this, which searches for an element by value and returns its key. Further, using the found key, we will remove the desired element from the array.

<?
$array = array('name' => 'Иван', 'lastname' => 'Иванов', 'site' => 'https://it-blog.ru');

if(($key = array_search('Иван', $array)) !== false){
     unset($array[$key]);
}
?>

As you can see, deleting an array element by value is quite simple, you just need to think a little.

The post Remove value from array in PHP appeared first on IAMCP-US.

]]>