r/webdev - I need your advice/thoughts on this (how does Google look at you?), you might be missing this out(like me), and it really can affect your work high
Strategy

I need your advice/thoughts on this (how does Google look at…


I’m a self-taught web developer and just started freelancing,

I develop small websites for small businesses and blogging-interested people around me.

after finishing the website, I used to create a Gmail account for this website and submit it to the search console to get indexed by Google.

in my first days, the website would take an average of 2weeks-to-month to get fully indexed by Google,

and it’s really important to get your website indexed quickly as possible to keep up with the current going events/trends, especially if you are a blogging or search results based website.

during my repetitive work of creating websites, the important thing that I noticed was: if the signup page when creating the Gmail account was this style1 instead of this style2, the whole website would be indexed by Google in just a couple of hours(instead of 2weeks-to-month),

r/webdev - I need your advice/thoughts on this (how does Google look at you?), you might be missing this out(like me), and it really can affect your work high

style2

r/webdev - I need your advice/thoughts on this (how does Google look at you?), you might be missing this out(like me), and it really can affect your work high

style1

and I would also receive “recommended changes” emails from the search console.

I remember once got the style1 signup page by using another browser than the one I usually use(but it is not always the case),

so I think that there is some sort of “Gmail trust score” or something like that, that Google uses to treat/process you across Google services.

I posted this to let you know that something like this exists and it is not all about the website content(it took me a lot of time trying just improving the content)

also if you can share your thoughts about how can I get the style1 page, and if you already know about something like this.



Source link

i need your guys help in determining which one of those 3 designs are your favorite? Thanks in advance :)
Strategy

i need your guys help in determining which one of those 3 de…


i need your guys help in determining which one of those 3 designs are your favorite? Thanks in advance :)

submitted by /u/Divdesigns
[comments]



Source link

PySimpleGUI: Working With Multiple Windows
Strategy

PySimpleGUI: Working With Multiple Windows


When you are creating graphical user interfaces (GUIs), you will often find that you need to create more than one window. In this tutorial, you will learn how to create two windows with PySimpleGUI.

PySimpleGUI is one of the easiest Python GUIs to get started with. It wraps other Python GUIs and gives them a common interface. You can read more about it in my Intro to PySimpleGUI or in my article for Real Python, PySimpleGUI: The Simple Way to Create a GUI With Python.

Getting Started

You will want to install PySimpleGUI to get started using it. You can use pip for that:

Making a Window Modal

PySimpleGUI provides a Window Element that you use to display other Elements in, such as buttons, text, images, and more. These Windows can be made Modal. A Modal Window won’t let you interact with any other Windows in your program until you exit it. This is useful when you want to force the user to read something or ask the user a question. For example, a modal dialog might be used to ask the user if they really want to Exit your program or to display an end-user agreement (EULA) dialog.

You can create two Windows and show them both at the same time in PySimpleGUI like this:

When you run this code, you will see a small Main Window that looks like this:

If you click on the “Open Window” button, you will get a new Window that looks like this:

This second window has a parameter named modal in it that is set to True. That means you cannot interact with the first Window until you close the second one.

Now let’s look at a way that you can shorten your code if you are creating a simple Window like the one above.

Creating a New Window In-Line

You don’t have to write a completely separate function for your secondary Window. If you’re not going to have a lot of widgets in the second Window, then you can create the Window as a one or two-liner.

Here is one way to do that:

In this example, when you click the “Open Window” button, it creates the secondary Window in a conditional statement. This Window calls read() directly and closes when the user chooses “Yes”, “No” or exits the Window. Depending on what the user chooses, the conditional will print out something different.

The Traditional Multiple Window Design Pattern

PySimpleGUI has a recommended method for working with multiple windows. It is mentioned in their Cookbook and in their demos on Github. Here is an example from Demo_Design_Pattern_Multiple_Windows.py:

When you run this code, you can open up several different windows that look like this:

You will want to try out using both of these methods to see which works the best for you. The nice thing about this method is that you have only one event loop, which simplifies things.

Wrapping Up

PySimpleGUI lets you create simple as well as complex user interfaces. While it’s not covered here, you can also use sg.popup() to show a simpler dialog to the user. These dialogs are can be modal too but are not fully customizable like a regular Window is.

Give PySimpleGUI a try and see what you think.



Source link

r/webdev - how to manipulate image-data in a better efficient way - canvas
Strategy

how to manipulate image-data in a better efficient way


I’m trying to manipulate ImageData, change it into a different image.

For image-data manipulation I’m using this (it just makes all the darker pixels darkest, and lighter pixels lightest)

  colorize = (pixels) => {
    //console.log(pixels)
    console.log(pixels.height)
    console.log(pixels.width)
    for(let l=0;l<pixels.data.length;l+=1){
      console.log(pixels[l] + " -- b")
      pixels.data[l] = pixels.data[l] > 128 ? 256 : 0;
      console.log(pixels.data[l])
    }
    return pixels;
    }

but this operations seems to be very slow for 200*201*(=40200)* pixels.

Here is the resulting output :

r/webdev - how to manipulate image-data in a better efficient way - canvas

with the function

Without this :

r/webdev - how to manipulate image-data in a better efficient way - canvas

without the function

My questions are –

  • How can I make is faster ?

  • Why is the console.log(pixels[l] + ” — b”) logging undefined –b ?

  • If the values is actually undefined, how come it’s returning 0 sometimes, sometimes 255. Is JS the next-gen quantum computing language ?(last part was joke)



Source link

Insomnia Harper DB TEST
Strategy

Build a REST API with Node.js and HarperDB


If you are building an application using Node.js, it can get a little overwhelming since there are a variety of databases to choose from and different ways to build APIs. One way to reduce development time and focus on the problem you are trying to solve is to use a Database as a service to store the data. The advantage of this approach is to use a cloud database system without purchasing hardware which can be cost and time-effective.

One such database service is HarperDB Cloud. To build REST APIs rapidly this service allows us to perform all database operations using a single endpoint. It supports a variety of programming languages such as JavaScript, Java, Python, and so on. Some of the features of HarperDB are the following:

  • Single endpoint API.
  • Allow JSON, CSVs file insertions.
  • Support SQL queries for full CRUD operations.
  • Supports Math.js and GeoJSON.
  • Limited database configuration required.

In this post, let’s build a simple REST API using Node.js and HarperDB Cloud to store some data. We are also going to use Express as the framework to build the Node.js server. It is a minimal and quite unopinionated framework.

Prerequisites

Before you begin this tutorial, you’re going to need the following:

  • Node.js version above 12.x.x installed on your local machine.
  • Access to a package manager such as npm or yarn.
  • Basic JavaScript and ES6 knowledge.
  • Access to a REST API client such as Postman or Insomnia.
  • Access to a HarperDB Cloud instance (free tier).

To continue with the rest of the tutorial, please make sure you have an account with HarperDB Cloud and are logged in.

Getting Started

Start by creating the project directory in a local development environment. Give this directory a name and navigate into it. Then, initialize this project to manage npm dependencies by creating a package.json file.

The --yes flag uses the default settings when initializing a package.json from the npm config you might have set up.

After the initializing step, let us add an express package. From the terminal window, run the command:

Next, create a new file called index.js at the root of the project with the following code to trigger a minimal server:

res.json(‘Express Server’));

app.listen(PORT, () => {
console.log(`⚡️[server]: Server is running at https://localhost:${PORT}`);
});” data-lang=”text/javascript”>

In the above code snippet, the app is an object provided by Express API for the developer to communicate with the application and bootstrap a server.

Go back to the terminal and trigger the common node index.js to start the server. This node command is the simplest way to trigger a development server when building APIs with Node.js. Now, open up your favorite REST client to test APIs. For the demonstration purpose, I am going to use Insomnia.

You can test the API endpoint by invoking a call to http://localhost:8000 and it is going to return the result as shown below.

Insomnia Harper DB TEST

Watching File Changes With nodemon

An essential development-related utility library that saves time when working on Node.js projects is nodemon. It’s a tool that helps the development of Node.js based applications by automatically restarting the Node application when file changes in the directory are detected.

To start using it in the current Express server, install it by using yarn add -D nodemon where -D flag is used to indicate that the dependency to install is a devDependency. After installing this dev dependency, open package.json file and add a start script as shown below.

Now, you can use either npm run start or yarn run start command to trigger the server. That’s it to set up a basic Node.js server using the Express framework.

Setting up an Instance of HarperDB Cloud

In the introductory section of this post, you get the idea of what HarperDB Cloud is and the features it supports. In this section, let’s create the first database instance to store the data for the REST API using this cloud database service.

Assuming by now you have access main dashboard screen as shown below. To create a new instance, click on the plus button.

HarperDB UI

Then select the HarperDB Cloud Instance option.

HarperDB Cloud Instance option

Fill in the details regarding the instance. Make sure to create a strong password and give a better username under Instance Credentials (I am keeping them simple for brevity).

Instance info

If you are on the free tier, leave everything in the screen below to default selections and click the button Confirm Instance Details.

Free tier options

After entering the details, it is going to ask you to re-confirm all the instance details you have entered and if everything is okay, press the button Add Instance.

Confirming details; Add Instance

Make sure to remember the username and the password you have entered here. They will be required to authenticate the Node.js server with the HarperDB Client. Once the instance of the cloud database is created, it is going to appear as shown below.

Successfully created instance

You can click on the instance card from the UI and will be welcomed by the first screen to add a schema.

Clicking instance card

A schema in HarperDB is necessary. It is equivalent to a collection of tables. Without an existing schema, you cannot create a new table and without a table, you cannot add or update data from the HarperDB instance. To proceed, the schema and the table has to be created. Let’s do it with the UI interface.

On the left-hand side, under the header where it says schemas, write in the name of your first schema.

creating your first schema

Once a schema is created, the option to add one or more tables appears. Let’s create the first table called books as shown below. Besides the name of the table, HarperDB also asks to enter or assign the field for a hash_attribute. This attribute is equivalent to the unique identifier for each record that exists in the table books. Traditionally, most data tables have id as a unique identifier so it is passed as the value.

Creating the first table

The schema, as well as the table, are now successfully created.

Successful schema and table creation

Let’s save all the credentials required for the Node.js server to connect to the database. Create a .env file at the root of the project with keys as shown below:

You are going to add your own HarperDB instance values here. Do not use the same values for each key as shown above, since it won’t work. This just to demonstrate that these values are not wrapped inside quotes.

Connecting HarperDB Cloud With a Node.js Server

To connect the HarperDB Cloud instance created in the previous section, let’s install a dependency called Harperive that is going to let us interact with the database by performing CRUD (Create, Read, Update, Delete) operations. Go back to the terminal window and run the command:

Once the dependency is installed, create a new directory called config, and inside it, create a new file called dbconfig.js.

To connect to the database instance, you require three things:

  • Database instance URL.
  • Database instance username.
  • Database instance password.

At the end of the previous section, all these values are saved inside a .env file as environment variables. Using the dotenv package, these environment variables are now accessible throughout the Node.js server app. Inside the dbconfig.js file, import dotenv package as the first line and then import harperive. Create a DB_CONFIG object that is going to be passed as the argument to harperive.client. The schema field in the DB_CONFIG object is optional. Since this demo app has only one schema, thus, to avoid mentioning the schema field again and again when sending a query to the database, its name can be passed here.

Add the following code snippet to the dbconfig.js file.

Exporting the db instance of the actual HarperDB client is going to allow us to query the database.

Setting up Body-parser

To set up routes or endpoints of the server application, you need to include body-parser in the index.js.

BodyParser parses incoming HTTP requests as middleware under req.body before routes or API have access to them and perform any further actions on them. A very useful and essential step when using forms in a web application.

The urlencoded method in the above snippet allows the body-parser middleware to extract data from form fields. In the REST client such as Postman or Insomnia, it is possible to send the data as form fields. The json method allows the JSON data to be extracted.

Query to Add a New Record

Since the database doesn’t have any records, let’s start by writing the first query to insert new data in the database. Create a new directory called api/ and inside it create a new file called index.js. Open index.js file and import the db from config/dbconfig.js file.

One of the main advantages of HarperDB is in querying the data from a database instance. It allows us to query the data either in the form of SQL queries or NoSQL queries. The advantage here is that the power of complex SQL queries can easily be used here to perform an operation. I am going to define all the queries in NoSQL form, however, do not forget to check official docs for more information on performing SQL queries here.

The first query is going to be called addBook. This query is going to insert the data incoming from an HTTP request.

Each of the query functions as in the above code snippet is going to have at least two parameters: request and response.

  • request: useful when creating or updating a new task and read data from the body (this where BodyParser works like a charm).
  • response: useful to fulfill that incoming request with a response from the server. Generally, it contains the correct status code of the HTTP status code. This HTTP status code determines whether the incoming request was fulfilled or if there is an error. This the part of the REST paradigm and is considered a best practice.

When inserting data using a NoSQL query, it is mandatory to specify the name of the table in the database. In the current case its books. Since you have already specified the Schema when creating a connection using the HarperDB client, there is no need to explicitly define it here. records in HarperDB are similar to rows of data with having each field as a column.

You may have noticed in the above query that I am not explicitly adding an id attribute to uniquely identify each data record. HarperDB automatically creates a unique id for each data record.

The data being inserted here has two fields. The title and the author for each book. They represent the name of the columns or attributes in each data record. The value of each of these fields is going to be the incoming value from an HTTP request, parsed by the body-parser middleware function.

Running the First Query to Insert Data

To insert the first data record in the database let’s create a route. Open index.js file in the root directory and import the api as routesController. A controller is a naming convention in an Express framework app. It is the business logic that binds the endpoints/routes that are going to define below to what action or operation they will perform on an incoming request on that particular route.

Go back to the REST client and make sure the Node.js server is running from the terminal window.

Add the endpoint which is http://localhost:8000/books, select the type of the request which is POST. Select option Form URL encoded and the two key-value pairs as shown below:

Post to http://localhost:8000/books

Press the Send button it an HTTP request to insert the data to the HarperDB is made. If it’s successful, a success message shown below is returned.

Successfully added book

Go back to the HarperDB studio and you are going to see the same data record being shown.

Do notice the two timestamp fields. They are auto inserted by the HarperDB and are auto-maintained.

  • __createdtime__: to record the timestamp when data is inserted.
  • __updatedtime__: to record the timestamp when any data field is updated for the last time.

Try to add more values to the database.

Query to Search by Value

HarperDB allows to search database records in a table by using a column field name which is also known as an attribute. Let’s add another query to get a data record when an HTTP request is sent just by searching the name of the author. Open api/index.js file and the following:

The data returned from the database is going to be in JSON format. Go back to the main index.js file and add another route.

Open the REST Client and make a request as shown below. The response of this HTTP request is going to be every data record that contains the value of the attribute author.

Querying Charles Dickens

Query to Search by Hash

Another important way to search for data in a table is by the unique identifier. HarperDB has a special method to do the same. This method is called searchByHash and only allows us to search the database table using the identifier specified as has an attribute. In the api/index.js file, add another query called getById.

When this query successfully runs, the result from the database is only going to show the title attribute of the data record. This is done by passing the name of an attribute as the value of the attributes property in the above snippet.

Add the endpoint in the main index.js file.

Go to the REST client and run the query.

Search by ID

Query to Delete the Data Record

To delete a record from the table in HarperDB is simple. All you have to do is pass the id or the unique identifier for the record stored in the table. The unique identifier, as you know, is stored as a hash value.

Add the following query to the api/index.js file.

Next, go to the main index.js file and add the endpoint.

Lastly, go back to the REST client, pass on the id of the data record to delete. On successful deletion, it gives a response back in the form of a message that is directly sent from the HarperDB instance. This is very helpful since this message response can be directly used with any REST client or sent to a front-end framework.

Successfully deleted data

Conclusion

Congratulations! You have reached the end of the tutorial.

I hope this post does convey to you to try the capabilities of HarperDB. I personally like how it supports both SQL and NoSQL queries as well as some advanced features like adding timestamps automatically and hashing unique ids in a consistent way across all data tables and schemas.

Resources:



Source link

r/graphic_design - Coolage: Embed your color palette on the web.
Strategy

Embed your color palette on the web. : graphic_design


Coolage is an innovative tool to showcase your color palette on the web by embedding them in pages, readmes, etc.

r/graphic_design - Coolage: Embed your color palette on the web.

Motivation

While developing web projects it’s hard to showcase the exact color visually from its HEX, RGBA, and HSLA. To resolve this I had written various functions and components which renders a small box filled with the given color. Over time it became quite repetitive and frustrating. So I thought why not create a tool to solve the problem.

Usage

Using the Coolage URL generator you can pick the color and the size of the placeholder which generates a URL in real-time. Click the copy icon and the URL will be copied to your clipboard. Voila! Paste the URL and you are good to go 🙂

Try it now -> https://coolage.funcs.io/

Source Code -> https://github.com/funcsio/coolage



Source link

r/web_design - Create new widget area within posts?
Strategy

Create new widget area within posts? : web_design


Hi everyone – hope web design is the best place to ask this question.

Essentially i’m trying to tidy up the bottom of posts on my website. I’ve attached a screenshot below and will just quickly explain what each element is.

  1. (and above) body content of the post

  2. Google Ad words advert (nice to have, not earning much anyway)

  3. plugin to track feedback (important to inform funders etc) – auto generated at the bottom of posts.

  4. theme elements – tags and suggested posts.

  5. blank space before footer

r/web_design - Create new widget area within posts?

what I would like to do is put my ad (2) into the blank space (5) – I know this doesn’t optimise positioning etc, but that’s not my aim with the website so i’m not bothered.

I think the solution is to create a widget space under the theme elements and then add in my HTML code as I normally would for a widget area. For reference the theme is hueman.

However, I don’t know how to do this and have no CSS knowledge. Can anyone suggest a work around?



Source link

r/webdev - How to achieve this layout when pulling from a cms?
Strategy

How to achieve this layout when pulling from a cms? : webdev


I have this blog post layout which I need to create, but it requires featured posts and reversing of the flex container, how would I achieve this if the list of posts is being pulled from an API using Array.map()

I know how to map the post list if they have a uniform layout or a first post being different but how would I achieve every third post having a different layout compared to the normal post layout?

I am using React

r/webdev - How to achieve this layout when pulling from a cms?



Source link

r/webdev - I made a simple extension for managing Microsoft 365
Strategy

I made a simple extension for managing Microsoft 365 : webde…


r/webdev - I made a simple extension for managing Microsoft 365

Hello everyone.

Over the last 18 months I’ve been administrating more and more parts of Microsoft 365, to the point where I had a sprawling set of bookmarks growing a little out of control (!) Thus, Centro 365 was born. It’s simple, but that’s all it needed to be.

Free for all, available for Microsoft Edge, Google Chrome and Mozilla Firefox. I hope some of you find it useful too.



Source link

r/webdev - ConnectDome : Match with developers, projects, and ideas using AI
Strategy

Match with developers, projects, and ideas using AI : webdev


ConnectDome helps you match with developers, projects, and ideas.

In detail, ConnectDome provides you with tailored project recommendations, 1:1 AI matches with developers we think you’d love to work with, our aim is to simply enable a lot of developers out there who aren’t able to work on their ideas just because they don’t have the time to or lack support from other developers.

r/webdev - ConnectDome : Match with developers, projects, and ideas using AI

Our tailored project recommendations help you work on other projects with one huge benefit, you get to be directly in touch with the creator of that project which can be a big advantage for some.

We just launched our alpha and it’s free to use 🙂

P.S I built it using Django, the infamous Python Backend Framework lol



Source link