NodeJS with Redis | Linux Hint

Redis is widely used as a caching server. At times, Redis is used as a database as well. It stores the data in a computer’s memory (RAM) directly. The advantage is that it can access the data very fast. The disadvantage is that the data it stores is temporary. If you reboot your computer, then all the data will be gone.

In this article, I will show you how to use Redis with Node.js. I will be using Node.js 10.x on Debian 9 Stretch in this article. But any modern version of Node.js should work. So, let’s get started. To get started you must have the following requirements:

  • js and NPM installed on your computer.
  • Redis installed on your computer.

You should be able to find articles on installing Node.js and NPM on your desired Linux distribution on LinuxHint.com. I’ve written a dedicated article on installing Redis on Ubuntu/Debian.

Starting Redis:

You can check whether redis service is running with the following command:

$ sudo systemctl status redis

As you can see, redis service is running.

If redis service is not running in your case, start it with the following command:

$ sudo systemctl start redis

Initializing the Project Directory:

First, create a project directory (let’s call it node-redis) with the following command:

Now navigate to the project directory ~/node-redis

Now create a package.json file:

Installing Redis Node.js Module:

There are many Redis clients for Node.js. The official website of Redis recommends redis. You can easily install the redis Node.js module using NPM (Node Package Manager).

To install redis Node.js module, run the following NPM command:

$ npm install redis –save

redis Node.js module should be installed.

Connecting to Redis using Node.js:

In this section, I am going to show you how to connect to Redis data store using Node.js.

First, create a new file connect.js in your project directory and type in the following commands in it:

Here, line 1 imports the redis module.

Line 2 creates a Redis client. As I am running Redis on the same computer as the Node.js programs are running, I didn’t have to specify the hostname or IP address and port where the Redis server is running. If you’re running Redis server on a different computer or server, then you will have to specify it here.

For example, let’s say, your Redis server is running on port 6379 on a computer which has the IP address 192.168.10.87, then you would write line 2 as:

let client = redis.createClient(6379, ‘192.168.10.87’);

Line 4-6 is used to print a message to the console if we can connect to the Redis server.

Line 9-10 is used to print a message to the console if we are unable to connect to the Redis server.

Now, run the connect.js Node.js script as follows:

As you can see, I am connected to the Redis server.

Storing Data in Redis Using Node.js:

In this section, I will show you how to store data (key-value pairs) in Redis data store with Node.js

First, create set1.js file in your project directory and type in the following lines in it:

Here, line 1 and 2 are the same as in connect.js.

On line 4, I set the callback function of the connect event to storeData. So, when our Redis client is connected to the Redis server, the function storeData is called.

On line 6-10, the callback function storeData is defined.

On line 7 and 8, I used set(key, value) method of RedisClient object to set the key name and country to value Mary Smith and USA respectively.

Now, run set1.js as follows:

As you can see, the key-value pairs are set.

Retrieving Data from Redis Using Node.js

In this section, I will show you how to retrieve data from Redis data store using Node.js.

First, create a new file get1.js in your project directory and type in the following lines:

Here, on line 4, getData function is set as a callback function for the connect event of RedisClient.

On line 6-9, the getData function is defined.

On line 7, I called the get(key, callback) method of RedisClient object. name here is the key of the value you want to retrieve. get() method calls the printValue callback function before it finishes running.

On line 11-18, the error first style callback function printValue() is defined. It accepts 2 arguments, error and result. If any error occurs, then it’s printed on the console and the function exits. If there’s no error, then the value for the certain key is printed on the console.

On line 8, the same thing happens.

Now, run get1.js as follows:

As you can see, the values for the keys name and country is retrieved from the Redis data store.

Storing Objects in Redis with Node.js:

You can store JavaScript objects in Redis data store.

First, create a new file set2.js in your project directory and type in the following lines in it.

Here, everything is the same as in set1.js file that I already explained earlier. The only difference is, I used client.hmset(key, object) method of RedisClient object in setData() callback function.

In line 7-10, I used client.hmset() method to store a JavaScript object in the Redis data store against the key C011.

Now run set2.js Node.js script as follows:

As you can see, the object is stored.

Retrieving Objects from Redis with Node.js:

In this section, I am going to show you how to retrieve objects from Redis data store.

Fist, create a new file get2.js in your project directory and type in the following lines in it.

Here, everything is the same as in get1.js script I explained earlier.

You can retrieve a JavaScript object very easily with client.hgetall(key, callback) method of RedisClient as in line 7-9.

Now run get2.js Node.js script as follows:

As you can see, the JavaScript object is retrieved from the Redis data store.

I showed you how to setup Redis with Node.js in this article. Now you should be able to read the redis Node.js module documentation at http://redis.js.org and learn more about it. Thanks for reading this article.

Source

How to Design a Logo Online – DesignEvo Logo Maker Review – NoobsLab

The logo creates a small window through which people recognize the identity of your company. Now to create a logo is a very important step for building brand identity, especially if you start an online business. Find yourself that you do not have any knowledge of Photoshop or any other design program, then think about hiring a professional designer to design your own logo, but find that you have a limited budget. Is there any other way to do it? In the post, we will talk about a free online logo service called

DesignEvo

Unlike other graphic design software, DesignEvo works online without downloading so you can design a special logo directly in your browser. DesignEvo contains thousands of professionally designed templates that can be easily modified to matches your brand, your company or your website.

DesignEvo is easy to use, and any computer user with internet knowledge can design his own logo. To get started, click the “Make a Free Logo” button on the homepage. It will take you to a new page where you will find more than 7000 ready-to-use templates. There are many categories available such as agriculture, animals, pets, technology, food, fashion, and education. You can also use the search box to find any particular logo. Once the logo template is selected, you will be taken to the editing canvas where you can make edits to your logo.

How to Edit Logo Text

To make the logo your own, you need to enter the name or slogan of your business. There are 100+ text fonts available from which you can choose to use and edit with a different style. By changing the size, color, spacing, alignment or adding a letter outline and curved effect, you will get the unique and perfect typography.

Add Icons and Shapes

DesignEvo offers millions of searchable icons. By entering a few keywords, you will find the icons that match your needs. Beyond that, DesignEvo also comes with many shapes, lines, symbols, banners, and other graphics. You can select the one you want and scale it to almost any size without loss of quality as they are all in vector format.

Preview Your Logo before Downloading

When you have finished editing the logo, you can preview how it will look like when placed on different projects. The preview function in DesignEvo offers you a variety of models so you can preview your logo on the business card, t-shirt, letterhead, website, company wall, etc.

Download Your Logo

DesignEvo offers three plans for you when you are going to download your logo. The free plan allows the free download of logos in JPG or PNG format with a maximum resolution of 500 x 500 pixels. For online uses such as putting it as a website banner or social media profile, this is enough. The basic plan costs you $19.99, which will let you download high-resolution logos in 5000px with a transparent background. For $39.99, you can even download a plus logo in vector format (PDF and SVG), and with copyright ownership of your logo. The prices are quite affordable and economical. You can see more details here.

Summary

DesignEvo provides a simple and effective solution for online logo creation. The most important thing is that you can design beautiful logos without the knowledge of any graphics editing program. With the templates provided in the gallery, vast collections of graphics and handy editing feature, everyone who needs a logo can play with DesignEvo and get a really impressive design in a fraction of the time.

Source

Linux Kernel 4.19 Released, Linus Torvalds Is Back, Linspire 8.0 RC1 Is Out, IPFire 2.21 Now Available and Recently Discovered Apache Vulnerability

News briefs for October 22, 2018.

Greg Kroah-Hartman released
Linux kernel 4.19
this morning and handed the kernel tree back to
Linus, writing “You can have the joy of dealing with the merge window.”

Linus Torvalds “is meeting with Linux’s top 40 or so
developers at the Maintainers’ Summit”, at the Open Source Summit Europe in
Edinburgh, Scotland, ZDNet
reports
. He isn’t scheduled to speak, but “this is his first step back
in taking over Linux’s reins.”

Linspire
8.0 RC1 was released
over the weekend. The stable release is
expected in December (don’t use this release in production environments),
and RC2, which should be more feature-complete, is expected in November.
Among other changes, in this version, iMac Pro support has been improved
and Oracle Java is now in the repositories. It uses the MATE 1.20.1
desktop, kernel 4.15 and Chrome 69.

IPFire 2.21 – Core Update 124 is out, and according to the release
announcement
, it “brings new features and immensely improves security and
performance of the whole system”. It’s now available on AWS
EC2
, is
updated to kernel version 4.14.72 and the security of its SSH daemon has
been improved, among other new features.

A recently discovered Apache vulnerability could affect thousands of
applications. Dark
Reading reports
that the issue is with “the way that thousands of code
projects are using Apache .htaccess, leaving them vulnerable to
unauthorized access and a subsequent file upload attack in which
auto-executing code is uploaded to an application.”

Source

NVIDIA GeForce RTX 2070 Linux Gaming Benchmarks Review

 

 

Last week following the launch of the RTX 2070 Turing graphics cards, I carried out some initial RTX 2070 compute benchmarks including of TensorFlow and more common OpenCL/CUDA workloads. The GPU compute performance for this $499+ Turing GPU was quite good and especially for INT16 test cases often beating the GTX 1080 Ti. Available now are the Linux gaming benchmarks for the GeForce RTX 2070 compared to an assortment of other NVIDIA GeForce and AMD Radeon graphics cards on Ubuntu 18.10.

 

 

As a quick recap, the GeForce RTX 2070 has 2304 CUDA cores, 1410MHz base clock, 1620MHz boost clock, and is capable of 42T RTX-OPS and 6 Giga Rays/s for ray-tracing, granted it will likely be some time before seeing any serious Linux games with RTX/ray-tracing support. The GeForce RTX 2070 graphics cards rely upon 8GB of GDDR6 video memory yielding 448GB/s of memory bandwidth.

 

 

The base pricing of the GeForce RTX 2070 starts at $499 USD while the Founder’s Edition retails for $599. With not receiving a review sample, I ended up buying the EVGA GeForce RTX 2070 XC GAMING (08G-P4-2172-KR). This EVGA GeForce RTX 2070 model ended up costing $549 USD and was the cheapest model available on launch day but since then more RTX 2070 graphics cards from NVIDIA’s AIB partners have become available, including around the $500 price point.

 

 

These GeForce RTX 2070 Linux gaming benchmarks were done using Ubuntu 18.10. All of the NVIDIA tests were done with the latest NVIDIA 410.66 driver while on the Radeon side was using the Linux 4.18 kernel and Mesa 18.2.2 as shipped by Ubuntu 18.10; while normally I am using Mesa Git for Radeon gaming benchmarks, currently there are several regressions leading to lower performance, etc. So for this comparison Mesa 18.2.2 + Linux 4.18 as the latest stable code makes the most sense.

 

The graphics cards freshly tested this comparison included the:

 

– GeForce GTX 970

– GeForce GTX 980

– GeForce GTX 980 Ti

– GeForce GTX TITAN X

– GeForce GTX 1060

– GeForce GTX 1070

– GeForce GTX 1070 Ti

– GeForce GTX 1080

– GeForce GTX 1080 Ti

– GeForce RTX 2070

– GeForce RTX 2080 Ti

– Radeon RX 580

– Radeon RX Vega 56

– Radeon RX Vega 64

 

 

A variety of Linux-native OpenGL and Vulkan games were tested on the brand new Core i9 9900K system, making for an even more interesting comparison. All of the benchmarks were carried out via the Phoronix Test Suite and in addition to the raw gaming performance are also performance-per-Watt and performance-per-dollar metrics.

 

Before getting to the results, if you appreciate all of my Linux hardware benchmarking, consider showing your support by joining Phoronix Premium to get access to the site ad-free, multi-page articles on a single page, and other benefits — that and PayPal tips also make it possible to purchase hardware such as the EVGA RTX 2070 used in this review.

Source

How create Mysql User, Database and set privileges to user on linux?

How create Mysql User, Database and set privileges to user on linux?

How create Mysql User, Database and set privileges to user

[ravi@linuxforfreshers.com~]$ mysql –u
root –p

password:

mysql> create user ‘ravi’@’localhost’
identified by ‘123456’;

mysql> create database if not
exists `ravidb`;

mysql> grant all on ravidb.* to ravi@linuxforfreshers.com
identified by “123456” with grant option;

[ravi@linuxforfreshers.com~]$ mysql ravidb
-u ravi -p

mysql> show databases;

mysql> use ravidb;

Source

Linux Today – Chrome for Linux, Mac, and Windows Now Features Picture-in-Picture by Default

Oct 22, 2018, 04:00 (Other stories by Marius Nestor)

Google’s engineers have been working for months to add Picture-in-Picture (PiP) support to the Google Chrome web browser, but the long-anticipated feature is finally here, enabled by default in the latest version for Linux, Mac, and Windows operating systems. The feature lets you detach a video in a floating window so you can watch it while doing something else on your computer. Picture-in-Picture (PiP) in Google Chrome works only on websites that implement this feature in their media player, but it can be enabled on any website with the Picture-in-Picture extension created by Fran??ois Beaufort. For YouTube videos, Chrome users will have to right-click twice on the playing video and choose the “Picture in picture” option.

Complete Story

Source

Install mod_deflate on Apache – LinuxAdmin.io

How to install mod_deflate

Mod_deflate is an apache module. Prior to having mod_deflate it was mod_gzip. Post apache 2.0 mod_deflate is used, it provides a slightly better compression than mod_gzip. It allows the size of certain file types to be compressed which in-turn allows clients to be able to download these files faster. This will cause the site itself to load faster for the clients as well as part of the formula for better page ranking. You can read more about mod_deflate on Apache.org.

Requirements:

This guide assumes you already have Apache running as a webserver. If you don’t, please see Install Apache on CentOS

Enable the mod_deflate module

The deflate module is part of the apache core package, so there is no need to compile additional modules, all that is required is to enable in the Apache configuration.

Verify its not already loaded:

# httpd -M 2>&1|grep deflate
#

Edit the main Apache configuration:

nano /etc/httpd/conf/httpd.conf

Un-comment the following line:

LoadModule deflate_module lib/apache/mod_deflate.soRestart apache to confirm the module loaded

service httpd restart

Check for the loaded module again, you should see it return a result

# httpd -M 2>&1|grep deflate
deflate_module (shared)

Configure mod_deflate

Create a new configuration file:

nano /etc/httpd/conf.d/deflate.conf

Add the following

<filesMatch “.(js|.css|html|txt)$”>
SetOutputFilter DEFLATE
</filesMatch>
DeflateCompressionLevel 7
DeflateMemLevel 8
DeflateWindowSize 10

DeflateCompressionLevel – this is the compression level applied, the default is 9, which is the highest level. The higher the compression level the more CPU it will use.
DeflateMemLevel – The amount of memory zlib, the compressing library can use. The default value is also 9, which is the highest.
DeflateWindowSize – The compression window size. By default the value is 15 which is the highest level.

This will compress .js, .css, .html, and .txt files. Attempting to compress images will actually return a larger file size so mod_deflate only really provides an advantage on text based files.

Once you have added the configuration settings, you would then just restart Apache to load everything in.

service httpd restart

That is it for adding mod_deflate to Apache.

Jun 26, 2017LinuxAdmin.io

Source

Apache Access Vulnerability Could Affect Thousands of Applications

Source: DarkReading – Posted by Brittany Day

Latest News
Vulnerabilities in Apache functions have been at the root of significant breaches, including the one suffered by Equifax. Now new research indicates that another such vulnerability may be putting thousands of applications at risk. Lawrence Cashdollar, a vulnerability researcher and member of Akamai’s Security Incident Response Team, found an issue with the way that thousands of code projects are using Apache .htaccess, leaving them vulnerable to unauthorized access and a subsequent file upload attack in which auto-executing code is uploaded to an application.


Read this full article at DarkReading

Only registered users can write comments.
Please login or register.

Powered by AkoComment!

Source

Kali Linux 2017.1 Xfce Installation on VMware Workstation

Kali Linux 2017.1 Xfce Installation
Kali Linux 2017.1 Xfce Installation on VMware Workstation

This video tutorial shows

Kali Linux 2017.1 Xfce installation

on VMware Workstation/Player step by step. This tutorial is also helpful to install Kali Linux Xfce 2017 on physical computer or laptop hardware. We also install

VMware Tools

(Open VM Tools) on Kali Linux 2017 Xfce for better performance and usability features such as Fit Guest Now, Drag-Drop File and Clipboard Sharing.

Kali Linux 2017.1 Xfce Desktop Installation Steps:

  1. Download Kali Linux 2017.1 Xfce ISO
  2. Create Virtual Machine on VMware Workstation/Player
  3. Start Kali Linux 2017.1 Xfce Installation
  4. Install VMware Tools (Open VM Tools)
  5. Test VMware Tools Features: Fit Guest Now, Drag-Drop File and Clipboard Sharing

 

Kali Linux 2017.1 New Features and Improvements

Kali Linux

is a Debian-based distribution which features several security and forensics tools. Kali Linux 2017.1 features drivers for RTL8812AU wireless chipsets, improved GPU support and there are now Azure and AWS images of Kali Linux for cloud instances. Kali Linux 2017.1 brings with it a bunch of exciting updates and features. As with all new releases, you have the common denominator of updated packages, an updated kernel that provides more and better hardware support, as well as a slew of updated tools.

Kali Linux Website:

https://www.kali.org/

What is Xfce Desktop Environment?

Xfce is a lightweight desktop environment for UNIX-like operating systems. It aims to be fast and low on system resources, while still being visually appealing and user friendly. It includes a window manager, a file manager, desktop and panel.

Xfce Desktop Website:

https://www.xfce.org/

Hope you found this Kali Linux 2017.1 Xfce installation tutorial helpful and informative. Please consider sharing it. Your feedback and questions are welcome!

Source

How to Set Different Wallpaper on Each Monitor on Linux GNOME

One of the great aspects of Linux is the customization that users can adopt to make their experience unique, and one of the easiest customization features is that of the desktop, with wallpapers. Usually, setting a wallpaper is as simple as right-clicking on the Desktop to bring up the Wallpaper manager and making a choice, but what if you have multiple monitors and would like a different image on each?

Release the Hydra! (paper)

HydraPaper is a slick tool that lets you set a different background on each monitor within the GNOME desktop. It is built with the GTK toolset which means that compatibility should be good, as will downloading the necessary dependencies. The application also supports MATE and Budgie desktops, but for this article we are concerned with GNOME.

Installation

By far the easiest way to install HydraPaper is via Flatpak and FlatHub.

To install Flatpak on Ubuntu, open a Terminal, add the PPA, and type the following commands:

sudo apt-add-repository ppa:alexlarsson/flatpak

Once this is done, then update to load the new repository and install with the following:

sudo apt-get update && apt-get install gnome-software-plugin-flatpak

After this is complete, if you decide to use FlatHub (which makes things easier) then add the repository:

sudo flatpak remote-add –if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

Now restart your system.

Flatpak apps will be available within the Ubuntu Software Center. Search for HydraPaper, and it should appear. When it does, then simply click to install as you would any other package in Ubuntu.

Additionally, Flatpak is now supported in several major distributions, meaning it is widely accessible to users. You can find full instructions for your distribution of choice here.

Ready, Set … Wallpaper!

Once installed, the application can be found in the normal Applications menu. Click on it to start as you would any other application. When it opens, the images within your Pictures folder will be displayed, which is the default location. Should you wish to change this, you can.

Add your own folders where you keep images, and then these can be used. However, one caveat is that the application doesn’t dig down into your folders for nested folders and the images within them. Only those within the top folder will be selected.

One great aspect of the application is the ease of use.

By clicking on the icon in the upper-left corner, you can choose your image folders. Then once these are loaded, it is just a case of clicking the wallpaper that you want on the respective monitor. HydraPaper will also identify the monitors that are connected and distinguish between them based on their connection type. As you can see below, it supports HDMI, DVI and others.

hydra-min

HydraPaper will also remember the wallpaper selections that you pick between reboots.

At this point it seems HydraPaper is pretty flawless. However, it is not all great news. There are times when HydraPaper tends to combine wallpapers that have previously been used across separate monitors into one image. This happens when you remove the external monitor or if your connection somehow fails. It joins them together, which can look fairly garish if you have two contrasting images creating a split-screen effect.

Neither does the application support more than two monitors. For this you would need an alternative solution such as Syncwall. Unfortunately, the only place I could find online was here and mainly for Ubuntu-based systems.

Uninstalling HydraPaper

Should you desire, you can uninstall HydraPaper by entering the following in the Terminal:

sudo flatpak uninstall org.gabmus.hydrapaper

So what do you think? Is HydraPaper going to be the way that you pick your wallpapers from now on, or do you have a much easier or perhaps effective method? Let us know in the comments section.

Source

WP2Social Auto Publish Powered By : XYZScripts.com