Help writing this program

Write a return function called averageFourTemperatures that accepts 4 integers in the parameter list, returns the average.

In the main function prompt the user for 4 temperatures and them in separate appropriately named variables.

Call the averageFourTemperatures, passing values and printing the returned average to the console.

How To Copy Files From One Directory to Another in Java: Example

Hello folks. I have been programming in Java for a long time, and you won't believe it, but there was no file copy method in the Java API until Java 7. Our options were either to: write it ourselves using a FileInputStream, a FileOutputStream, and a buffer to copy bytes from one to the other; or, better yet, use the FileChannel.transferTo() method or the Apache Commons FileUtils, which was a lifesaver in those days and still is today. 

JDK has evolved now, and you have a decent API to copy files from one directory to another. In this article, I'll show you both the pre-Java code for copying files from one directory to another as well post Java 7 code, which makes this task a lot easier.

Best Free CRM Software

A business without a CRM is at a disadvantage.

It is extremely tough to manage all of your customers while keeping track of everything else without any dedicated system. Leads are dropped, opportunities are missed.

The good news is that CRM software can help you automate and efficiently manage all these customer-related processes. The great news? A lot of the CRM software available today is free.

This software allows you to take all of your data across multiple platforms and departments and store it in one convenient place.

I’ve put together a list of the best free CRM software tools to help you decide which is right for your business.

The Top 8 Best Free CRM Software Tools: 

  1. HubSpot — The Best Free CRM for Massive Contact Lists
  2. Insightly — The Best Free CRM Software for Project Management
  3. Streak — The Best Free CRM Software for Gmail
  4. SuiteCRM — The Best Free Open-Source CRM Software
  5. Flowlu — The Best Free CRM Software for Financial Management
  6. Freshworks — The Best Free CRM for Tech Support
  7. Bitrix24 — The Best Free CRM For Your First Year In Business
  8. Really Simple Systems — The Best Free CRM for Sales Forecasting

Now you know the list of free CRMs I’ll be reviewing, let’s dive into each of them.

#1 – HubSpot — The Best Free CRM for Massive Contact Lists

  • Up to a million contacts, forever
  • Track all contact records easily
  • Forms and popups included
  • Live chatbot available
Try for free

HubSpot is a great choice when it comes to the number of contacts it offers. You’re looking at 1,000,000 contacts with no time limit or expiration date—no matter the size of your team.

There’s no doubt such a vast number of contacts would be more suitable for larger businesses in general, but it’s also a useful feature to have as you grow your business. You won’t have to worry about maxing your contact list out any time soon.

The CRM software’s contact records allow you to view everything about a contact, too. From your history of emails to the calls, meetings, and deals you’ve made.

Additional options include the ability to create forms and popups where you can start to acquire data about a contact, and there’s even a live chatbot to gather information and schedule meetings for your business.

In other words, HubSpot is aware of just how vital customer data is and keeps it all in a readily accessible place.

Other features of the CRM include:

  • Email tracking
  • You can set recurring tasks
  • Shared history options
  • Sales automation
  • Social media integration
  • Task planning, scheduling, and tracking
  • Live chatbots to capture leads
  • Call monitoring and email monitoring

I’ve said the HubSpot CRM is free to use, and that’s true, but there are extra features available for those that want more. For instance, higher pricing tiers allow for automation, traffic analytics, user roles, and Salesforce integration, to name a few.

It’s a good idea to get familiar with the CRM first before deciding which of these enhanced features you need.

#2 – Insightly — The Best Free CRM Software for Project Management

  • Easy, accessible project pipeline
  • Project automation included
  • Pre-built project templates
  • Gmail add-on available
Try for free

Managing projects, large and small, is at the core of any business. You’ll need a robust system to be able to handle day-to-day operations. Insightly is my top pick for free CRM software that can manage multiple projects of all sizes.

Each project and sale are presented in an easy-to-use pipeline that you can customize to fit your business. What’s more, recurring projects can be automated to keep things running smoothly while saving you time.

It’s worth mentioning that the free version of Insightly is aimed at a two-person team, but higher pricing tiers can provide you with more users. It’s a good starting point to see what the software can do, but it wouldn’t be suitable for larger teams.

Perhaps the most significant thing is that Insightly is just so simple to use for everything from building email campaigns to using pre-built templates for other crucial projects.

Visually speaking, you can also expect a clean, clear, and highly functional CRM that gets the job done without the fuss.

Project management proficiency aside for one second, Insightly also provides the following features:

  • Native iOS and Android mobile apps
  • Permission management
  • Powerful Google and Microsoft calendar integration
  • Quote generation
  • Reporting and statistics
  • Scheduled reporting
  • Social media integration
  • Tags and keywords

A useful Gmail add-on also allows you to view email opens, create leads, and projects.

The three tiers available for Insightly are Plus, Professional, and Enterprise. Plus starts at $29 per user per month and is billed annually. Professional and Enterprise are $49 and $99 per user per month, respectively.

#3 – Streak — The Best Free CRM Software for Gmail

  • Fully integrates into Gmail
  • Create pipelines in your inbox
  • Auto-populate contact info
  • “Integrate
Try for free

I mentioned that Insightly had a Gmail add-on to help you manage projects from your inbox, but Streak takes that concept to the next level.

Simply put, this free CRM software allows you to control your entire business through Gmail. There’s no additional app or platform to log in and manage—it literally lives inside your inbox.

The immediate advantage of this is that you can use a familiar and most likely already frequently used email platform for so much more. For example, Streak allows you to create pre-made pipelines for your business projects, sales, and lead lists, all within the email interface.

Even more impressively, contact details from your emails can seamlessly be pulled into Streak, including company information. This process auto-populates, too, giving you more information to work with in less time.

Keep in mind that Streak’s free plan is for two users only. While you can certainly do everything you could possibly need with that in the right situation, larger teams will miss out unless you upgrade to the paid-for plans.

Other features of Streak include:

  • “Send later” email scheduling
  • Mass email/mail merge
  • API access (including webhooks)
  • Tasks/reminder/Google Calendar integration
  • Import/Export via Google Sheets
  • Call logs
  • Meeting notes

There are four pricing plans for Streak overall, including the free plan. Solo starts at $15 per user per month, Pro is $49, and Enterprise is $129, each with increasingly more features.

#4 – SuiteCRM — The Best Free Open-Source CRM Software

  • Massive customization capabilities
  • Wide range of free add-ons
  • Self-hosting available
  • 30-day free trial on paid upgrades
Try for free

One of the best things about SuiteCRM is that it’s both free and open-source CRM software.

By open-source, I mean the software itself can be customized almost any way you want. It also means it’s available to the public to enhance it collaboratively.

SuiteCRM is an excellent choice for businesses with a particular need to modify the software to their liking.

For example, let’s say you’re a business that needs the functionality of collecting multiple leads from numerous sources and then converting them into customers. Not a problem. SuiteCRM’s open-source and flexible nature allows you to tailor its modules to your bespoke goals.

Even better, there’s a wide variety of free add-ons that can be downloaded and added to the software to help you further achieve specific goals.

Other features include the following:

  • Customer support
  • Marketing automation
  • Landing pages and web forms
  • Calendar management
  • Client portals
  • Contact database
  • Real-time data and reporting
  • Sales reporting
  • Search functionality
  • Third-party integrations

The pure SuiteCRM is free to use and doesn’t expire, so there won’t be many extra costs from that point. You’ll be able to self-host the CRM, too, if you desire. However, it’s worth noting that customer support is only available through the forum for all but the highest package.

The other versions of SuiteCRM, which are hosted, and can be scaled to your business, are not free to use indefinitely—be aware that very few hosted CRMs are—but they do come with a 30-day trial, giving you more than enough time to decide.

#5 – Flowlu — The Best Free CRM Software for Financial Management

  • Custom financial transactions
  • Automatic status updates
  • Auto-sent customer communication
  • Five possible upgrades available
Try for free

Flowlu shines on the financial side of things, making it a top choice for businesses that produce many invoices and need to keep up to date with transactions. If that’s you, then you might just have found the right software.

The creators consider it to be “business management software” first and foremost. There’s a deep focus on quotes, payments, and other financial priorities.

If you’re selling to a customer, for example, then you can create a custom invoice, choose your preferred payment method, and when you’ve been paid, the status of the invoice will update automatically.

What’s more, an automatic email can be sent out to the customer thanking them, and the entire transaction is then logged in the invoice record. Handy indeed.

Flowlu also includes the following valuable features:

  • Mind maps
  • Records and revenue management
  • Sales reporting
  • Security and encryption
  • Status tracking
  • Task management
  • Time tracking
  • Workflow management

Flowlu is free CRM software, but it’s worth mentioning that quite a few features are locked out if you remain on the initial plan. If you’re a business that needs multiple accounts for a large team, keep in mind that the free plan only offers two places and no user access control.

There are five overall tiers to the pricing, with the Enterprise plan offering everything along with a custom domain and two-factor authentication for extra security.

#6 – Freshworks — The Best Free CRM for Tech Support

  • 24-hour weekday support
  • Phone and email support included
  • “Wide
  • 21-day free trial of paid upgrades
Try for free

How important is tech support for your business? If the answer is very important, then Freshworks is an excellent choice. Freshworks’ free CRM software comes with phone and email support five days a week, 24 hours a day.

The highly-rated customer support makes this software ideal for smaller businesses, especially when ongoing help and care are crucial to long-term success.

With that said, any business that puts customer support as a top priority on their list should consider the software.

Some of the other highlights of the Freshworks CRM include the following:

  • Lead scoring
  • Lost deal analysis
  • Mobile integration
  • Open and click notifications
  • Pipeline dashboard
  • Preview reports
  • Record calls
  • Revenue analytics
  • Sales campaigns
  • Team segmentation

Individual add-ons can improve the CRM software further, but these can quickly become costly, which seems somewhat at odds with the rest of what Freshworks offers.

Still, I’m nitpicking here, and you shouldn’t let that stop you from checking the software out.

The best part is the startup plan that offers top-notch support is free forever, making it a generous proposal. Pricing for other plans starts at $29 per month per user. The free trial of the more advanced tiers includes everything, too, and gives you 21 days to see whether the software is worth buying. 

The top tier of the pricing even features a dedicated account manager that can personally resolve issues and relay information to other specialists. Either way, whatever choice you make, Freshworks is unlikely to let your team down.

#7 – Bitrix24 — The Best Free CRM For Your First Year In Business

  • Serves up to 12 users
  • 5 GB storage included
  • “Task
  • Free trial of full platform available
Try for free

While other CRMs on this list offer a free trial of their software, some even indefinitely, they are typically held back by limited features or a smaller number of users.

That’s where Bitrix24 comes in, and really, the strongest point about this CRM software is that the starting free plan provides businesses with enough to really get going. For some small companies, it may even be all they need.

Bitrix24 provides a cloud-based CRM for up to 12 users, 5 GB of online storage, and most of the significant features of the other plans just scaled down a bit.

In other words, for the cost of $0, you’re getting an awful lot. It also allows you to try the software out, almost in its entirety, before deciding to opt for a more premium plan. It’s a good deal, and I’m impressed.

Other features of Bitrix24 include:

  • Landing page creator
  • Group chats
  • Badges
  • Ticket management
  • Website forms
  • Approval workflows
  • Voice and video calls / conferencing
  • Synchronous document editing
  • Version control
  • Customizable callback widget
  • Document management
  • Task management

Of course, just because the free starting plan is generous doesn’t mean that Bitrix24 is necessarily the best free CRM for your business.

For example, I think the customization features of Bitrix24 aren’t the strongest, and the UI can be confusing to navigate.

But for just getting your business off the ground, it’s a very solid choice. 

#8 – Really Simple Systems — The Best Free CRM for Sales Forecasting

  • Weighted and unweighted forecasting
  • Mitigate long-term risk
  • Customer support included free
  • Auto-populate customer data
Try for free

Sales forecasting is a vital part of any business, allowing you to see your available budget and what a given strategy or route will potentially return to you. It also helps mitigate risk, keeping your business healthy in the long term.

As the name suggests, Really Simple Systems makes sales forecasting as simple as it needs to be. This free CRM software provides you with a weighted and unweighted revenue forecast for all of your projects.

Effectively, the weighted figure gives your business a clear understanding and probability of closing a deal. The fields in which this data is located can be auto-populated, too, saving essential time for other areas and giving you more data to work with overall.

Accuracy is key to sales forecasting, and the more data you have, the more accurate you’ll be.

Other features I like in the Really Simple Systems free CRM are:

  • Free customer support
  • Two-way email integration
  • Quotations
  • User permission levels
  • Integrated marketing module
  • Web-to-Lead forms
  • Automated campaigns
  • In-product help drawers and tutorials

The free plan of Really Simple Systems isn’t free forever, and after the trial expires, you’ll need to upgrade to one of their other plans. It’s also worth mentioning that the free plan lacks quite a few features of the other more premium plans, including email integration, user profiles, and design templates.

The Starter package is $14 per user per month, the Professional is $30, and the Enterprise plan is $46 per user per month. The document storage on the free tier is only 100 MB, which can be easily used—if that’s important for your business, another CRM plan might be better.

How to Find The Best Free CRM Software For You

You’re interested in a free CRM, but you’re not sure which? Fret not. Here, I’ll explain the CRM categories and then go into the specific factors to consider in your search. 

The first thing to think about is the kind of CRM you want for your business.

There are three main types of CRM software to consider:

  1. Operational
  2. Analytical
  3. Collaborative

The difference between these types of CRMs is the areas they focus on overall.

For example, an operational CRM system focuses on capturing leads and streamlines and automates the process. It would be suitable—although not exclusively—for small businesses that prefer automation and those which run a linear sales process. HubSpot is an example of an operational CRM.

An analytical CRM is all about the data, as you might assume from the name. So, here we’re talking about customer data and the insights you can get from it. Information from multiple channels will be structured and available for a team to use—for example, they might use the data which details customer preferences to improve customer relationships. Freshworks CRM delivers robust analytics through custom reports and a win-loss analysis.

The last type is the collaborative CRM. This is CRM software that looks at all of the interactions a business has with its customers. The central aim is to share customer information between departments to bolster the overall customer service and eliminate problems. This would be suitable for businesses with many different departments and those happy to share the data around in a considerable manner. Bitrix24 is an example of a good collaborative CRM.

In addition to the above three types of CRMs, these are the other key factors you need to think about when deciding on the right free CRM software for you:

Self-Hosted vs. Hosted

A CRM system can be self-hosted or hosted. What that essentially means is the difference between sorting out the server and security for yourself or letting someone else take care of it.

For example, most of the free CRMs on this list can take care of the hosting for you, and it’s included in almost all of the free and paid plans. SuiteCRM is an example of software that can be self-hosted or hosted through the cloud.

There are advantages and disadvantages of self-hosting vs. hosting a CRM.

In a nutshell, self-hosting gives you more control and is generally cheaper, but you will have to potentially manage and fix any problems that occur, such as a cybersecurity attack.

Hosted CRMs are generally more expensive and give you less control—in theory—but you have access to top customer service teams and better infrastructure. It’s the peace of mind knowing that any problems will be fixed by a team of experts that make this a popular choice, certainly for larger businesses.

Number of Users

The number of users that free CRM software allows varies greatly. As you might expect, most of the free CRMs on this list limit the number of users on the free plan but significantly increase it on the paid plans. My advice is to think carefully about the number of users your business needs.

For instance, does your business consist of a large team? Or maybe it’s a two-person effort?

Bitrix24 is generous and offers 12 users on their free plan, while conversely, Insightly is aimed at two people on their initial offering. The last thing you want is a team member locked out of the software. However, a two-person setup might be all you need.

Customer Support

The level of total customer support you’ll receive when using a free CRM isn’t consistent across the board. For example, Freshworks provides customer support five days a week on their free plan, while Flowlu and Streak’s offering is more basic.

It comes down to what your company needs right now.

Is it crucial that you receive as good customer support as possible at this stage in your business? Or would you rather test the waters with a free CRM and then upgrade later for better support? Think about what you need in your situation.

Type of Free Plan

The type of free plan on offer with CRM software fits into one of two main scenarios: the software is free forever but is probably limited in some ways. Or, there’s a free trial available for the software with most of the key features available, but once it expires, you will have to upgrade to a paid plan.

For instance, on our list, we can see that SuiteCRM is free forever but limited in some features, but if you’re happy with what that offers, you need not pay anymore. Others, such as Really Simple Systems, have free trials, and once they expire, you will need to move onto a paid plan to continue to access it.

The critical question is: what’s best for you and your business right now?

Summary

There isn’t any free CRM software on this list I would recommend entirely over the others because it really does depend on your business context. The one thing I can say for sure is that every single one of them has plenty to offer.

If you’re looking for customer service as a top priority, go for Freshworks, but if financial management is more the thing you need, Flowlu is a good bet. For a great free starting plan, Bitrix24 has you covered.

Maybe managing everything from Gmail is important. If so, I say go for Streak. Or perhaps powerful sales forecasting is what you’re after instead? In that case, Really Simple Systems is a strong choice.

Need CRM software that can manage countless contacts? HubSpot offers 1,000,000. For everything project management, you should turn to Insightly, and SuiteCRM is an open-source delight.

Use this guide carefully, and you’ll be up and running with free CRM software before you know it.

sqldatareader reader = cmd.executereader() incorrect syntax near

Hi all.

i have a trouble of my testing project. could anyone can guide me to solve the problem. million thanks~~ newbie of programming.

error : System.Data.SqlClient.SqlException: 'Incorrect syntax near 'card'.'

string connectionstring = ConfigurationManager.ConnectionStrings["library2ConnectionString"].ConnectionString;

SqlConnection con = new SqlConnection(connectionstring);

        con.Open();

        string sql = "Select librarycardid, password" + 
            "from library card information" +
            "where librarycardid = '" + librarycardid + "'" + 
            "and password = '" + password + "' ";

        SqlCommand cmd = new SqlCommand(sql, con);
        SqlDataReader reader = cmd.ExecuteReader();  <<<<<<error at here 

        if (reader.HasRows)
        {

            Label3.Text = " login success";
        } else {
           Label3.Text = "login fail";
        }

con.Close();

Amazon Lambda Connector: Mule 4

AWS Lambda is a serverless architecture that runs your code in response to events and automatically manages the underlying compute resources for you. You can use AWS Lambda to extend other AWS services with custom logic or create your own back-end services that operate at AWS scale, performance, and security.

In this article, I will present how MuleSoft can call AWS Lambda functions using the Amazon Lambda connector in Mule 4. 

An Introduction to Incident Response Roles

In the world of reliability engineering, folks talk frequently about “incident response teams.” But they rarely explain what, exactly, an incident response team looks like, how it’s structured, or which roles organizations should define for incident response.

That’s a problem because your incident response team is only as effective as the roles that go into it. Without the right structure and responsibilities, you risk leaving gaps in your incident response plan that could undercut your team’s ability to respond quickly and efficiently to all aspects of an incident.

How to add score counter?

How to add score counter to rock paper scissors game? I can't get score counter work. (Player wins, Computerwins)
I got it working without functions but now when I added them I don't just get it how to do it...

#include <iostream>
#include <math.h>
#include <string>

int numGen ();
int choiceConverter (std :: string);
void DisplayComputer (int);
void winner (int, int);

int main ()   
{
std :: string playerChoose;
int player;
int compChoice;
int rounds = 0;
int gains = 0;
int machineGains = 0;

// Ask the user how many rounds to play? 
std :: cout << "How many rounds do you want to play?" << std :: endl;  
std :: cout << "Enter rounds>";
std :: cin >> rounds;

for (int round = 1; round <= rounds; round ++)
{

std :: cout << "Round number:" << round << "/" << rounds << std :: endl;

std :: cout << "\nSelect rock, paper or scissors:";
std :: cin >> playerChoose;
std :: cout << "\ nYour selection is:" << PlayerChoose << "\ n";



compChoice = numGen ();
player = choiceConverter (playerChoice);
displayComputer (compChoice);
winner (compChoice, player);
}

} 
int numGen ()
{
std :: srand (time (0));
int randomi = rand ()% 3 + 1;

return randomi;
}

int choiceConverter(std :: string player1) 
{
int numEquiv = 0;

if (player1 == "rock")
character code = 1;
else if (player1 == "paper")
character code = 2;
else if (player1 == "scissors")
character code = 3;    
return numEquiv
}
void displayComputer (int player2)
{
if (player2 == 1)
{
std :: cout << "The computer chose rock \ n";
}
else if (player2 == 2)
{
std :: cout << "The computer chose paper \ n";
    }
else if (player2 == 3)
{
std :: cout << "The computer chose scissors \ n";
}
}

void winner (int player1, int player2)
{

if ((player1 == 1 && player2 == 2) || (player1 == 2 && player2 == 3) || (player1 == 3 && player2 == 1))
{
std :: cout << "\nYou won the game! \ n \ n";

}
else if ((player1 == 1 && player2 == 3) || (player1 == 2 && player2 == 1) || (player1 == 3 && player2 == 2))
{
std :: cout << "\ nComputer won the game! \ n \ n";

}
else
{
std :: cout << "\nDraw \ n \ n";
}   
}

Chef 101: Getting Started With Automation

In this blog post, you’ll take a look at some practices that can help you get a running start with your Chef automation and the principle of Policy as Code. It’s intended for any IT professional or Chef newcomer.

Prologue: What Do I Need To Know?

This post is designed to be beginner-friendly. You don’t need any coding experience to follow along — just an interest in automation, and curiosity about how best to implement it with Chef. That said, let’s define some terms before we dive in:

An Introduction To Quasar Framework: Building Cross-Platform Applications

In this article, I will explain how to use Quasar Framework and its state-of-the-art UI (which follows Material guidelines) to build a notes app. The app will get its data from and store its data to Firebase. This tutorial is meant for anyone interested in building cross-platform applications that work well across all devices simultaneously. At the end of the article, you should have a proper understanding of what Quasar is, how to get started creating apps with Quasar, and also how to use Firebase.

To follow along in this article, you should have:

  • an understanding of HTML, CSS, and JavaScript;
  • at least a little experience with Vue.js;
  • Node.js version 10 or above and npm version 5 or above installed on your machine.
  • knowledge of how the command-line interface (CLI) works.

The deployed app is available for viewing, and the final code is on Github.

What Is Quasar Framework?

Quasar Framework is an open-source Vue.js-based cross-platform framework whose motto is: “write code once and simultaneously deploy it as a website, a mobile app and/or an Electron app”. It has many features that enable you, as a web developer, to build apps on desktop and mobile and to create progressive web apps (PWAs) using technologies such as Cordova, Electron, and the web (Vue.js).

Why Quasar Framework?

Quasar is an easy-to-use but powerful UI kit comprising a lot of UI components, layout elements, and helpers. Together, these elements provide a full-featured toolset for building responsive front-end apps, without your having to make use of many different UI libraries. It does the heavy lifting for you, allowing you to focus on features and not boilerplate.

In summary, Quasar offers support for many build modes, including:

  • single-page applications;
  • progressive web applications;
  • server-side rendering;
  • mobile apps (iOS and Android), using Cordova or Сapacitor;
  • multi-platform desktop apps, using Electron;
  • browser extensions.
Getting Started

To get started, let’s look at how to install Quasar on your local machine and set up a project.

Installation

There are three ways to start using Quasar:

  • embedding to an existing project via a content delivery network (CDN);
  • installing using the Vue.js CLI Quasar plugin;
  • installing using the Quasar CLI.

For this tutorial, we will be using the third method, which is the Quasar CLI. The first thing to do is install the Quasar CLI globally on your computer, or check whether it is installed by running the following commands in your CLI:

quasar -v #check if quasar has been installed previously

yarn global add @quasar/cli
# or
npm install -g @quasar/cli

Once this is done, you can now move on to setting up the project.

Project Set-Up

Run the following command in your CLI:

quasar create <folder_name>

Following this, you are going to be asked some questions. Here is my full configuration for the app we will be building.

Now we can move into the project folder and start up the application using the following commands:

cd <folder_name>
quasar dev

With the steps above complete, our app should be running on http://localhost:8080. This is what we should see:

Quasar’s Folder Structure

The default application structure for Quasar is intended to be a great starting point for developers to build any type of application. You can organize the application however you like and create directories whenever you need them.

.
├── public/                  # pure static assets (directly copied)
├── src/
│   ├── assets/              # dynamic assets (processed by Webpack)
│   ├── components/          # .vue components used in pages and layouts
│   ├── css/                 # CSS/Stylus/Sass/… files for your app
│   ├── layouts/             # layout .vue files
│   ├── pages/               # page .vue files
│   ├── boot/                # boot files (app initialization code)
│   ├── router/              # Vue Router
│   ├── store/               # Vuex Store
│   ├── App.vue              # root Vue component of your app
│   └── index.template.html  # template for index.html
├── .editorconfig            # editor config
├── .gitignore               # GIT ignore paths
├── .postcssrc.js            # PostCSS config
├── babel.config.js          # Babel config
├── package.json             # npm scripts and dependencies
├── quasar.conf.js           # Quasar app config file
└── README.md                # readme for your app

The source folder consists of about seven major directories that a beginner should care about:

  • quasar.conf.js
    This is the brain behind any Quasar application, because most configurations are done in this file. Amazingly, Quasar handles most of the complex configurations needed by the various tools and packages that you might use in an application. Some of these configurations are for:
  • src/assets
    The assets directory contains your uncompiled assets, such as Stylus or Sass files, images, and fonts.
  • src/components
    This is where all of your reusable components will live. These components make up the different parts of the application and can be reused and imported into your pages, layouts, and even other components.
  • src/css
    You will not find this in Vue.js, but Quasar provides this so that we can have all of our global CSS in Sass form. It consists of two files: app.sass is where all of our styles will go, while quasar.variables.sass contains all of the reusable variables we would want to make use of when styling our app. You could ignore the CSS directory if you feel it’s of no use to you.
  • src/layouts
    This helps us create defined layouts for an app without repeating code. This is useful when you want to include sidebars or fixed bottom bars or have distinct layouts for mobile and desktop.
  • src/pages
    The pages directory contains our application’s views and routes. Our pages are injected into the app and managed through Vue Router in /src/router/routes.js. This means that each page needs to be referenced there.
  • src/router
    This holds the routing configuration of our app. It consists of two folders:
    • /src/router/index.js holds the Vue Router initialization code.
    • /src/router/routes.js holds the routes of the app, loading our layouts alongside the routes or pages in the app.
      You might not need to do anything to the index.js file in a small project, but if your project will have routes, you will need to add them to the routes.js file.
Building a Notes App

When building an application with Quasar, the first thing we will want to do is create a layout. Quasar has made this process a lot easier than any other framework by making use of a layout builder. For our notes app, we will want something like the following, which is quite similar to the default layout but with a few modifications:

App Layout

In the sidebar of Quasar’s documentation, you will see the “Layout and Grid” option. When you click it, a dropdown will appear with more options, one of which is “Layout Builder”. Click on “Layout Builder”, which will bring you here:

This allows us to choose the options we want and remove the ones we don’t. Then, we would generate the code to paste in the layout file.

The first option helps us to pick the layout parts, while the second allows us to configure the layout parts. Finally, we export the generated layout.

If you want the exact same layout as mine, use the code below:

<template>
  <q-layout view="lHh lpR fFf">
    <q-header elevated class="bg-primary text-white">
      <q-toolbar>
        <q-btn dense flat round icon="menu" @click="left = !left" />
        <q-toolbar-title>
          <q-avatar>
            <img src="https://cdn.quasar.dev/logo-v2/svg/logo-mono-white.svg" />
          </q-avatar>
          Title
        </q-toolbar-title>
      </q-toolbar>
    </q-header>
    <q-drawer show-if-above v-model="left" side="left" bordered>
      <!-- drawer content -->
    </q-drawer>
    <q-page-container>
      <router-view />
    </q-page-container>
  </q-layout>
</template>

<script>
export default {
  data() {
    return {
      left: false
    };
  }
};
</script>

Remove the default layout and paste the code above or the code that you have generated into src/layouts/MainLayout.vue.

The code above is divided into three sections: the header (navbar), the drawer (sidebar), and the page container (which contains the router view).

We’ve made use of the state-of-the-art UI to style the whole page. As I said earlier, when using Quasar, you won’t need additional heavy libraries such as Hammer.js, Moment.js, or Bootstrap.

We will be adding data to the sidebar and editing the navbar. Once you’ve saved, you will notice our app now looks like this:

Let’s work on the layout, adding some items to the sidebar and changing the title of the app, If you scan the layout code that we added, you will see where we are supposed to edit and add these various items.

Here is what my layout looks like after I’ve added items to the sidebar and changed the title:

And here is the code:

<template>
  <q-layout view="lHh lpR fFf">
    <q-header elevated class="bg-primary text-white">
      <q-toolbar>
        <q-btn dense flat round icon="menu" @click="left = !left" />
        <q-toolbar-title class="text-h6">
          My Notes
        </q-toolbar-title>
      </q-toolbar>
    </q-header>
    <q-drawer show-if-above v-model="left" side="left" bordered>
      <q-list class="q-pt-xl">
        <q-item clickable v-ripple to="/">
          <q-item-section avatar>
            <q-icon name="home" size="md" />
          </q-item-section>
          <q-item-section class="text-weight-bold">Home</q-item-section>
        </q-item>
        <q-item clickable v-ripple to="/about">
          <q-item-section avatar>
            <q-icon name="info" size="md" />
          </q-item-section>
          <q-item-section class="text-weight-bold">About</q-item-section>
        </q-item>
      </q-list>
    </q-drawer>
    <q-page-container>
      <router-view />
    </q-page-container>
    <q-footer class="bg-grey-2 text-black ">
      <q-toolbar>
        <q-toolbar-title class="text-subtitle2">
          Designed and Built For this article.
        </q-toolbar-title>
      </q-toolbar>
    </q-footer>
  </q-layout>
</template>
<script>
export default {
  data() {
    return {
      left: false
    };
  }
};
</script>

We removed the logo in the navbar and edited the text, then added a list to the sidebar, making use of Quasar’s state-of-the-art UI. Check out the list items, and copy the code of any you wish to use.

App Design

Earlier on, I said I was going to use Quasar’s state-of-the-art UI (which follows Material guidelines) to build a notes app, and that’s what we will be doing now. Explaining the whole process in an article like this is difficult, but the “Style & Identity” section of Quasar’s documentation covers it well.

This will be a one-page app (index.vue), and here is the code, without any styling applied:

<template>
  <q-page class="">
    <div class="q-pa-md">
      <q-input
        bottom-slots
        v-model="newNoteContent"
        placeholder="Write your note here..."
        counter
        autogrow
        maxlength="300"
      >
        <template v-slot:after>
          <q-btn round dense flat icon="send" />
        </template>
      </q-input>
    </div>
    <q-separator size="10px" />
    <q-list bordered class="rounded-borders" style="max-width: 600px">
      <q-item-label header>You have 3 Note(s)</q-item-label>
      <div>
        <q-item>
          <q-item-section top>
            <q-item-label caption class="text-grey-9">
              He who has imagination without learning has wings but no feet.
            </q-item-label>
          </q-item-section>
          <q-item-section top side>
            <div class="text-grey-9 q-gutter-xs">
              <q-btn size="13px" flat dense round icon="delete" />
            </div>
          </q-item-section>
        </q-item>
        <q-separator size="1px" />
      </div>
      <div>
        <q-item>
          <q-item-section top>
            <q-item-label caption class="text-grey-9">
              He who has imagination without learning has wings but no feet.
            </q-item-label>
          </q-item-section>
          <q-item-section top side>
            <div class="text-grey-9 q-gutter-xs">
              <q-btn size="13px" flat dense round icon="delete" />
            </div>
          </q-item-section>
        </q-item>
        <q-separator size="1px" />
      </div>
      <div>
        <q-item>
          <q-item-section top>
            <q-item-label caption class="text-grey-9">
              He who has imagination without learning has wings but no feet.
            </q-item-label>
          </q-item-section>
          <q-item-section top side>
            <div class="text-grey-9 q-gutter-xs">
              <q-btn size="13px" flat dense round icon="delete" />
            </div>
          </q-item-section>
        </q-item>
        <q-separator size="1px" />
      </div>
    </q-list>
  </q-page>
</template>
<script>
import db from "src/boot/firebase";
export default {
  name: "PageIndex",
  data() {
    return {
      basic: false,
      fixed: false,
      newNoteContent: ""
    };
  }
};
</script>

In the code above, we have an input field from Quasar. We’ve attached a v-model to get the data from the input field once the “Submit” button is clicked. We also have a list of items that will be used to display each note, and each list item has an icon used to delete that particular item when clicked.

Setting Up Local Data

At this point, the design of our app is in place. The next thing we will do is create an array that would contain all of our notes. We will ensure that we can add to and delete from this array before setting up Firebase.

Here is the array that we will be making use of in our app for now. Later, we will remove this array or comment out the code.

notes: [
  {
    id: 1,
    noteContent: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Ea vereprehenderit aspernatur mollitia saepe cupiditate pariatur natus accusantium esse repudiandae nisi velit provident corporis commodi eius fugiat reiciendis non aliquam."
  },
  {
    id: 2,
    noteContent: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Ea vereprehenderit aspernatur mollitia saepe cupiditate pariatur natus accusantium esse repudiandae nisi velit provident corporis commodi eius fugiat reiciendis non aliquam."
  },
  {
    id: 3,
    noteContent: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Ea vereprehenderit aspernatur mollitia saepe cupiditate pariatur natus accusantium esse repudiandae nisi velit provident corporis commodi eius fugiat reiciendis non aliquam."
  }
]

Fetching Data

We now have our array. Let’s add these data to our app. Because we understand Vue.js, all we will do is loop through this array using the v-for directive, use the data gotten from the array, and then put the content wherever we want it to appear.

<div v-for="noteContent in notes" :key="noteContent.id">
  <q-item>
    <q-item-section top>
      <q-item-label caption class="text-grey-9">
        {{ noteContent.note }}
      </q-item-label>
    </q-item-section>
    <q-item-section top side>
      <div class="text-grey-9 q-gutter-xs">
        <q-btn
          size="13px"
          flat
          dense
          round
          icon="delete"
          @click="deleteNote(noteContent)"
        />
      </div>
    </q-item-section>
  </q-item>
  <q-separator size="1px" />
</div>

We also added a click event handler to the delete button, so that it loads this function whenever it’s created.

Adding Notes

Let’s see how to add notes to our app by using the input field. We will use JavaScript’s unShift() methods, which adds one or more elements to the beginning of an array and returns the new length of the array.

The first thing to do is to add a click event handler to the button.

<q-btn round dense flat icon="send" @click="addNote" />

Then, proceed to create this method in the script area.

methods: {
  addNote() {
    let newNote = {
      id: this.notes.length + 1,
     note: this.newNoteContent
    };
    this.notes.unshift(newNote);
    this.newNoteContent = "";
  }
}

In the code above, we created an object for the new note, which comprises the ID and the note itself, and then we added this newNote to the array of notes via the unShift() method.

Deleting Notes

Finally, before proceeding to use Firebase in our app, let’s see how to delete a note. The first thing would be to add an event listener to the delete icon:

<q-btn
  size="13px"
  flat
  dense
  round
  icon="delete"
  @click="deleteNote(noteContent)"
/>

And then we would create a method:

deleteNote(noteContent) {
  let noteId = noteContent.id;

  //doing this to get the real id of the notes
  let index = this.notes.findIndex(noteContent => noteContent.id === noteId);
  this.notes.splice(index, 1);
}

In this code, we got the id of the particular note that we want to delete through the parameter passed to the click event method that was created. Then, we made use of the splice method to remove only that item from the array.

Firebase

Now that these two pieces of functionality work, let’s now see how we can use Firebase in Quasar to add, fetch, and delete data. Firebase will also give us real-time data syncing across all devices. The data in our app won’t be very much, because it’s just for the purpose of learning. In case you are thinking of something big that would be used by millions of people, check out the pricing page.

Firebase is application development software from Google that enables us to develop iOS, Android, and web apps.

Setting Up Cloud Firestore

To get started, visit firebase.google.com and click on either the “Go to console” link in the top-right corner of your screen or the “Get started” button (ensure that you sign in with your Google account).

This will bring us to the console area, where we can create a project. Click on the “Add a project” button, and a form to create your project will appear. The first question will request the project’s name, which could be anything; for this article, we will call it “notesApp”. Let’s also disable Google Analytics because ours is a mini-app.

Click on the “Create project” button (this might take few seconds, so be patient). Then, click on “Continue”, so that we can create our cloud Firestore.

In the sidebar, click on “Firestore”, and then “Create database”.

This will bring up a modal. Click on “Start in test mode”, which will make it easy for us to start working with our database. Bear in mind that, “The default security rules for test mode allow anyone with your database reference to view, edit and delete all data in your database for the next 30 days”.

Click on “Next”, leave the default Cloud Firestore location, and then click on the “Enable” button. Once it loads, our database will be fully ready for us to use.

Note: The Firebase database is made up of collections, and these collections contain documents, and each document is a JavaScript object that has fields in it.

Let’s get started by creating a new collection for our notes.

To create a collection, click on “Start collection”. A modal will pop up for you to enter the collection ID — meaning, a name. Then, click on the “Next” button.

You can now start creating the documents and fields for each note. Auto-generate the ID of the document to ensure that it is unique by clicking “Auto-ID” beside the document field.

Click “Save”, and continue to create more documents. In the end, this is what my database looks like:

Now that we are done, let’s see how to connect Firebase to our app. Go to “Project overview” in the sidebar, and let’s add this to a web app by clicking the “Web” button.

A form will appear for us to “Add Firebase” to our web app. We will give it the same name, “notesApp”, and register the app (don’t check the “Firebase hosting” field).

Once it has loaded, it will bring up an SDK to help us initialize our database in the app. We won’t do it this way, although we will need some information from the generated SDK. The right way to do this in Quasar is to import the modules that we need and use a boot file.

So, leave that tab open, and let’s see how to add the Firebase SDK and initialize Firebase in our Quasar app.

The first thing to do would be to install Firebase in our project with npm.

npm install --save firebase

Once installation is complete, we are going to initialize our app’s connection to Firebase by creating a boot file, so that we have immediate access to the database when our app is ready.

A boot file helps us to run code before the app’s Vue.js root component is instantiated. Quasar’s documentation has more information about boot files and when to use boot files.

To generate a boot file, we will run this command in our CLI:

quasar new boot firebase

Note: You don’t need to use Firebase as the name of the boot file.

Once this is done, you will notice that the file is now created in the boot folder. To make use of this newly created boot file, we’ll need to add it to the quasar.config.js file’s boot array.

Let’s go back to the newly created boot file. Delete all of the code there because we don’t need it. We’ll import the modules that we need and configure our database. Paste in the following code:

import firebase from "firebase/app";
import "firebase/firestore";

const firebaseConfig = {
  // ...
};

// Initialize Firebase
firebase.initializeApp(firebaseConfig);

Here, we’ve imported Firebase itself and Firestore, and we’ve initialized Firebase, making use of the config, which we will be adding now.

At this point, we are almost done configuring our app. We need to add our unique configuration, which was provided in the SDK that was generated when we added Firebase to our web app. Copy only the configuration, and paste it into our array.

We should now have something like this:

import firebase from "firebase/app";
import "firebase/firestore";
const firebaseConfig = {
  apiKey: "AIzaSyDRcq5PXJSi5c5C8rl6Q6nudIJqTFaxXeA",
  authDomain: "notesapp-ffd7c.firebaseapp.com",
  projectId: "notesapp-ffd7c",
  storageBucket: "notesapp-ffd7c.appspot.com",
  messagingSenderId: "18944010047",
  appId: "1:18944010047:web:ddfb46fc6bc8bba375158a"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);

One last thing, since we are making use of Firestore, is that we’ll need to initialize the cloud Firestore by adding this code to our boot file (the last line):

let db = firebase.firestore();
export default db;

This db will give us access to our Firestore database. We also exported it so that we can use it anywhere in our app.

At this point, you might still be a little confused, but if you have followed this guide, then you will have properly initialized Firebase for your application. You can read more about adding Firebase to your JavaScript project in the documentation.

Fetching Data From Firebase

If you have followed the guide so far, everything should work fine once you launch your app. Now let’s grab the notes created in the database and display them in our app.

For this, we will be making use of the .onSnapshot hook, which will be fired any time the data in our collection changes. This will tell us whether a document has been added, removed, or updated. For this guide, we will only deal with the addition and removal of documents. Using hooks like this makes real-time syncing across devices possible. Let’s get started.

The first thing to do would be for us to get access to the database by importing it into the index page of our app.

import db from 'src/boot/firebase';

Then, create a mounted hook, because we want to fetch our data immediately after the app has loaded.

mounted() {
  db.collection("notes").onSnapshot(snapshot => {
    snapshot.docChanges().forEach(change => {

      let noteChange = change.doc.data();

      if (change.type === "added") {
        console.log("New note: ", noteChange);
        this.notes.unshift(noteChange);
      }
      if (change.type === "modified") {
        console.log("Modified note: ", noteChange);
      }
      if (change.type === "removed") {
        console.log("Removed note: ", noteChange);
      }
    });
  });
}

In the code above, we are simply grabbing our notes collection, and every time there is a change in the collection, the onSnapShot method will be fired, which will return a snapShot of all our data. All of these data will be objects with type properties. These type properties will tell us the type of change that has happened and give us access to the data that was either added, modified, or removed.

This might sound confusing, but you will understand what we are doing as you read on.

If you save your code and check the console environment, you will notice that each note has been logged out. We can now push these objects to the notes array that we created earlier, so that we can display real-time data in our application.

The first thing to do is delete or comment out the objects in the notes array, so that we have something like this:

notes: []

Then, pass the objects to this array:

this.notes.unshift(noteChange);

Your code should now look like this:

if (change.type === "added") {
  this.notes.unshift(noteChange);
}

At this point, if you load the app, you will notice that you have successfully fetched your data from Firebase.

Adding Data to Firebase

Let’s see how to add a note to our notes collection in this app. At this point, if you try to use the input field to add a note, it will work but the note will disappear once you refresh the page because it’s not stored in any database.

To do this with Firebase, all that is needed is to update the addNote() method that we created earlier.

addNote() {
  let newNote = {
    // id: this.notes.length + 1,
    note: this.newNoteContent
  };
  // this.notes.unshift(newNote);

  db.collection("notes")
    .add(newNote)
    .then(docRef => {
      console.log("Document written with ID: ", docRef.id);
    })
    .catch(error => {
      console.error("Error adding document: ", error);
    });

  this.newNoteContent = "";
},

The first thing we did here was remove the ID that is used when we made use of the previous array, because we are now going to auto-generate the ID from Firebase. We also removed the unshift() method; it’s no longer useful because data is being fetched for our app once there is an update using the snapShot hook.

If we look at the code responsible for updating the Firestore db, all we are passing to the collection (notes) is the new object (newNote), and this function will automatically generate an ID for each of our documents. The documentation has more information on adding data to Firebase.

Deleting Data From Firebase

We are almost done with our app, but we need to be able to delete data in our app from Firebase. Currently, the delete function works, but if you reload the app, the deleted data will reappear.

As we did before, we are going to delete these data (or documents) from Firebase using the unique ID generated by Firebase.

Currently, we don’t have access to the ID. To access it, we will add it to the noteChange object:

noteChange.id = change.doc.id;

Once that is set, deleting data will be as easy as adding it. All we have to do is go to the deleteNote(noteContent) method that we created previously, delete the previous code, and make use of this:

deleteNote(noteContent) {
  let noteId = noteContent.id;
  db.collection("notes")
    .doc(noteId)
    .delete()
    .then(() => {
      console.log("Document successfully deleted!");
    })
    .catch(error => {
      console.error("Error removing document: ", error);
    });
}

This checks the notes collection for a document with the specified ID and then deletes it. But if we save our code now and click the delete icon, the data will delete but won’t leave the app’s interface unless we refresh our code, meaning that the snapshot hook needs to be updated. Go to the snapshot hook for removed, and add this code:

if (change.type === "removed") {
  console.log("Removed note: ", noteChange);
  let index = this.notes.findIndex(
    noteContent => noteContent.id === noteChange.id
  );
  this.notes.splice(index, 1);
}

This simply gets the ID of the post that we deleted and removes it from the interface.

With that done, we have built an app with Quasar that works with Firebase. One major advantage of Quasar is that it enables us to simultaneously deploy our project as a website, mobile app, or Electron app.

To deploy for iOS, Cordova needs to be installed on our local machine. A MacBook is highly preferable. Navigate to your CLI, and install Cordova globally:

$ npm install - g cordova

To install on Windows, you would make use of Electron. The documentation properly explains how to do this.

Conclusion

In this guide, we have built a notes application using Quasar and Firebase. By following this guide, you are now in a position to improve on and add your own features and functionality. Here are a few ideas to get you started:

  • Implement functionality to modify notes.
  • Add dates, so that you can order the data by date.
  • Style the app, and make it more creative.
  • Add images.
  • A lot more.

Useful Resources

Increasing code quality with Hyperlambda

Fundamentally Hyperlambda is really just a Turing complete markup language, with some added capabilities resembling features from XSLT and XPath. You could argue Hyperlambda is the programming equivalent of YAML. On the index of "programming level abstractions" if we argue that CISC x86 assembly code is at level 1 (the bottom level) and C# and Java is at level 5, while Python and PHP are at level 10 - Hyperlambda is at level 100+ somewhere.

Of course, the point being, that 95% of the times you need a low level programming construct, Hyperlambda implicitly creates your C# objects and ties these together 100% correctly out of the box. This reduces the cognitive complexity of your resulting app's code by orders of magnitudes. To illustrate this difference, please have a look at the following code snippet taken from Microsoft's official documentation for how to correctly create an HTTP request from C#.

How to Draw Mountains

A mountain’s beauty can see from above the land’s surface. Mountain ranges usually consist of a group of mountains. In addition to cities situate in lowlands, there are also cities situated on mountains with harsher conditions. Many mountains hold religious significance as they uses for millennia for spiritual and religious reasons. The highest mountain in...

The post How to Draw Mountains appeared first on .