Shubham Ankit

Shubham Ankit

1571304866

Cyberattacks: 10 steps to protect your website

Every day, countless websites become the target of attacks. Many website operators do not care about the security of their pages, although this is an extremely important task. So that you don’t (anymore) become a target of such attacks, here is the most important information to prevent attacks.
There are infinite types of attacks in this area. Maybe you have been a victim of an attack yourself and are now here to protect your site. Of course you can’t protect yourself against everything, but your site is much safer if you follow the following steps!

  • SSL Certificate
  • SQL Injection
  • XSS (CORS)
  • DDOS Protection
  • Passwords
  • Session Management
  • Public Informations
  • Validation
  • Updates
  • Backups
  • Conclusion

SSL Certificate

SSL certificates for websites are responsible for secure communication between client and server. Secure (encrypted) connections can be recognized by the lock in front of the domain and the preceding https:// as here:

In addition, certification authorities such as GlobalSign confirm the authenticity of a domain/website. This ensures that it is a real website and not a phising page or the like. Especially for pages with login you should always make sure that this lock appears in front of the domain.

If your website deals with personal data, you absolutely need an SSL certificate. The use must also be mentioned in the privacy policy in an appropriate paragraph. For more information, please contact your data protection officer.

In order to get such a certificate, you can buy it from your hoster for a fee. Alternatively you can generate a free certificate from Let’s Encrypt. If you use Plesk to manage your hosting, you can install the extension for free and protect your domains and mail servers.

FunFact: Google certifies its certificates itself ;)

For more information on SSL Certificates, contact GlobalSign.

SQL Injection

SQL Injection is the term used to describe the attack of introducing foreign SQL code into the server-side system of the server. This allows the attacker to obtain, manipulate, delete or even execute code on the target server.

Here is a small example. A MySQL statement is:

SELECT name, place, phone FROM index WHERE ID=4;

“4” was written into the SQL statement by a user input and everything is fine. However, if now the user input

4; UPDATE name SET place='irgendwo' WHERE ID=4

the SQL statement looks like this:

SELECT name, place, phone FROM index WHERE ID=4; UPDATE name SET place='irgendwo' WHERE ID=4;

An update command has been inserted into the statement. The attacker simply changed a record from the database. In this example, only an unimportant value is changed, but such attacks can also be adapted to password columns and important or sensitive data.

Protecting yourself from SQL injections is a big task and is not in the hands of every website operator. If you program database applications yourself, you should read more about it on the internet, like this one. If you only manage your website with plugins, you should read the step Updates carefully.

Here you can find a PHP 7.* database class, which is secured against SQL Injections and you can use for free for your website.

XSS (CORS)

XSS means cross-site scripting and is an attack that executes malicious code on the clients. How this happens is quite simple: In a form on a website you can of course write normal text. Let’s assume we have a guestbook where the text is simply displayed on the website, i.e. the user input is loaded 1:1 into the website. However, if the attacker enters JavaScript tags with malicious code instead of a text and this is embedded on the website, it is executed in the browser for all users. This is of course a considerable security risk.

CORS stands for Cross-Origin Resource Sharing and can prevent such attacks. It prohibits (or allows) connections for certain scripts or URLs. Therefore, you should definitely check your CORS configuration on the server.

Since this malicious code reaches the server via user input, it is advantageous to check every user input. You should refrain from blacklists. With blacklists, all user entries that are on this list are rejected. But since you never know which attack is used, it makes more sense to program whitelists. This means that you only allow user input that is on this list.

Further information about CORS can be found here.

DDOS Protection

DDOS stands for Distributed Denial of Service and is an attack in which the server is brought to its knees by overload. This happens because a huge computer network (botnets) “spammes” the server with connections.

https://de.wikipedia.org/wiki/Denial_of_Service#/media/File:Stachledraht_DDos_Attack.svg

Fortunately, there are services that can stop such attacks. A provider is e.g. Cloudflare. Usually these services are however liable to pay the costs. Therefore you should consider carefully whether you need protection against DDOS attacks.

Password

This step is important for everyone. Not only administrators, but also private individuals should pay attention to secure passwords. This includes upper and lower case letters, numbers, digits and special characters. In my opinion passwords should be at least 8 characters and longer.

If you have chosen secure passwords, I don’t think it’s important to change them regularly. Since you then have a large number of passwords and they are hard to remember, you can make life easier with password managers like KeePass.

Session Management

Logins require sessions to know which user is logged in and to provide all services. Session data is stored to uniquely identify a user. In the past these were often attached to the URL:

example.com/dashboard?sid=89234nFJK98nkdf823njkFsdn387$

If you now send this link to show this page to friends, it is directly logged in. The session ID was sent with the link and the server thinks it is the same user. With acquaintances this is normally not so bad. But imagine, you share this link in a social network…

That is why many years ago it was decided to find another solution. That’s why today you can only find links that look like this:

https://example.com/dashboard

Here the session ID is stored in a cookie, which is only stored in the temporary memory of the user. Others who call the link have no possibility to take over his session.

So when you’re doing your session, keep that information in mind. :)

Public Informations

There’s information that doesn’t belong in the public domain. For websites this includes e.g. the PHP version and the file path of the website.

To illustrate this, I have here a very revealing example. With Google I have the possibility to search not only for certain search terms, but also with parameters e.g. for file extensions and quotations. So I can use this search to display pages that have a phpinfo file publicly accessible. In this file the complete PHP configuration of a server is revealed and we get a lot of interesting information about the server.

I entered this in the Google search:

ext:php intitle:phpinfo

With this search I got about 12,000 results. One of the first search results gave me this result:

Below are hundreds of lines with all PHP settings. This is fatal, because this server is still running PHP version 4.4.2. Already since 2008 the support and the further development of this PHP version is stopped and contains serious security holes.

Source: https://de.wikipedia.org/wiki/PHP#PHP_4

You should therefore delete these sensitive files after use or protect them with a password (e.g. via a .htaccess file).

You should also make sure that your display_errors variable is set to Off on live systems, because even there, attackers get information about the internal filesystem. It’s even worse with database errors. In the worst case, the access data is output here. This should be prevented at all costs. In your PHP settings you can instead specify that error messages should be written to a log file.

Validation

The subject of validation is a large area and interesting and even essential for developers. Validation is about checking and validating data sent from the client to the server according to certain rules. In doing so, invalid user data is rejected because it can also contain malicious code. This step is also important against XSS attacks.

Especially when data is written to a database, validation is even more important. This even allows server commands to be executed. In the worst case, even data can be deleted or servers shut down. This attack is called SQL Injection.

So it becomes clear what I mean by validation, here is an example in PHP:

<?php
$id = $_GET["id"];
$type = $_GET["type"];


// if id is not a number
if(!is_numeric($id)) {
    exit("id not valid");
}

// type must be one of the following strings
$types = array("slow", "slower", "normal", "fast", "faster");
if(!in_array($type, $types)) {
    exit("invalid type");
}

// Parameters successfully validated
// Code goes here

exit("success");
?>

Here the parameters id and type are passed as GET parameters. The script is aborted if id is not a number or type is not in the whitelist $types. The script is terminated by exit(). If the conditions do not apply, the rest of the code can be executed.

Updates

Almost every website is based on a CMS (Content Management System), such as WordPressDrupal or Joomla. There are regular updates to ensure security. And this is not simply said so. Again and again new security gaps are found and closed as fast as possible by the developers. For this reason your CMS installation should always be up to date. With most CMS you can set e-mail notifications to be informed about new updates. You should use this and check your pages at regular intervals.

The same applies to the installed plugins. If updates are available, you should install them regularly.

Furthermore, your host system should always be up to date. Make sure you have the latest Linux (or Windows), PHP and MySQL installed. Again, patched versions will be released regularly to ensure user safety.

Before you update your site and plugins to the latest version, you should create a backup if something goes wrong during the update and you have to restore the old version.

Backups

Regular backups also contribute to the security of your website. If you notice today that your site has been compromised, you can easily go back to an old state and update it to close the vulnerabilities.

Depending on which server system you use, you can configure backups. Many hosters offer regular snapshots for free or for an extra charge. If you manage your hostings via Plesk, you can use the backup manager or directly create a shell script which backs up directories like /var/www/vhosts to an external backup storage. Your host will be sure to help you choose the right backup solution.

Conclusion

As you can see, there are many possible vulnerabilities on a website. However, if you take these steps seriously, the risk of a successful attack is much lower. If you look at statistics on how many websites are hacked, I think that many website operators take security lightly. But you’re smarter now and don’t make these mistakes.

Originally published by WebDEasy  at* *https://webdeasy.de

================================

Thanks for reading :heart: If you liked this post, share it with all of your programming buddies! Follow me on Facebook | Twitter

Learn More

☞ Kali Linux Tutorial For Beginners

☞ Kali Linux Boot Camp - 2019

☞ Learn Ethical Hacking From Scratch

☞ The Complete Cyber Security Course : Hackers Exposed!

☞ Ethical Hacking With Python, JavaScript and Kali Linux

☞ The Complete Ethical Hacking Course: Beginner to Advanced!

☞ Hacking in Practice: Certified Ethical Hacking MEGA Course

☞ Learn Python & Ethical Hacking From Scratch

☞ The Complete Ethical Hacking Course

#security #web-development

What is GEEK

Buddha Community

Cyberattacks: 10 steps to protect your website
John  Smith

John Smith

1657107416

Find the Best Restaurant Mobile App Development Company in Abu Dhbai

The era of mobile app development has completely changed the scenario for businesses in regions like Abu Dhabi. Restaurants and food delivery businesses are experiencing huge benefits via smart business applications. The invention and development of the food ordering app have helped all-scale businesses reach new customers and boost sales and profit. 

As a result, many business owners are searching for the best restaurant mobile app development company in Abu Dhabi. If you are also searching for the same, this article is helpful for you. It will let you know the step-by-step process to hire the right team of restaurant mobile app developers. 

Step-by-Step Process to Find the Best Restaurant App Development Company

Searching for the top mobile app development company in Abu Dhabi? Don't know the best way to search for professionals? Don't panic! Here is the step-by-step process to hire the best professionals. 

#Step 1 – Know the Company's Culture

Knowing the organization's culture is very crucial before finalizing a food ordering app development company in Abu Dhabi. An organization's personality is shaped by its common beliefs, goals, practices, or company culture. So, digging into the company culture reveals the core beliefs of the organization, its objectives, and its development team. 

Now, you might be wondering, how will you identify the company's culture? Well, you can take reference from the following sources – 

  • Social media posts 
  • App development process
  • About us Page
  • Client testimonials

#Step 2 - Refer to Clients' Reviews

Another best way to choose the On-demand app development firm for your restaurant business is to refer to the clients' reviews. Reviews are frequently available on the organization's website with a tag of "Reviews" or "Testimonials." It's important to read the reviews as they will help you determine how happy customers are with the company's app development process. 

You can also assess a company's abilities through reviews and customer testimonials. They can let you know if the mobile app developers create a valuable app or not. 

#Step 3 – Analyze the App Development Process

Regardless of the company's size or scope, adhering to the restaurant delivery app development process will ensure the success of your business application. Knowing the processes an app developer follows in designing and producing a top-notch app will help you know the working process. Organizations follow different app development approaches, so getting well-versed in the process is essential before finalizing any mobile app development company. 

#Step 4 – Consider Previous Experience

Besides considering other factors, considering the previous experience of the developers is a must. You can obtain a broad sense of the developer's capacity to assist you in creating a unique mobile application for a restaurant business.

You can also find out if the developers' have contributed to the creation of other successful applications or not. It will help you know the working capacity of a particular developer or organization. Prior experience is essential to evaluating their work. For instance, whether they haven't previously produced an app similar to yours or not. 

#Step 5 – Check for Their Technical Support

As you expect a working and successful restaurant mobile app for your business, checking on this factor is a must. A well-established organization is nothing without a good technical support team. So, ensure whatever restaurant mobile app development company you choose they must be well-equipped with a team of dedicated developers, designers, and testers. 

Strong tech support from your mobile app developers will help you identify new bugs and fix them bugs on time. All this will ensure the application's success. 

#Step 6 – Analyze Design Standards

Besides focusing on an organization's development, testing, and technical support, you should check the design standards. An appealing design is crucial in attracting new users and keeping the existing ones stick to your services. So, spend some time analyzing the design standards of an organization. Now, you might be wondering, how will you do it? Simple! By looking at the organization's portfolio. 

Whether hiring an iPhone app development company or any other, these steps apply to all. So, don't miss these steps. 

#Step 7 – Know Their Location

Finally, the last yet very crucial factor that will not only help you finalize the right person for your restaurant mobile app development but will also decide the mobile app development cost. So, you have to choose the location of the developers wisely, as it is a crucial factor in defining the cost. 

Summing Up!!!

Restaurant mobile applications have taken the food industry to heights none have ever considered. As a result, the demand for restaurant mobile app development companies has risen greatly, which is why businesses find it difficult to finalize the right person. But, we hope that after referring to this article, it will now be easier to hire dedicated developers under the desired budget. So, begin the hiring process now and get a well-craft food ordering app in hand. 

Dylan  Iqbal

Dylan Iqbal

1561523460

Matplotlib Cheat Sheet: Plotting in Python

This Matplotlib cheat sheet introduces you to the basics that you need to plot your data with Python and includes code samples.

Data visualization and storytelling with your data are essential skills that every data scientist needs to communicate insights gained from analyses effectively to any audience out there. 

For most beginners, the first package that they use to get in touch with data visualization and storytelling is, naturally, Matplotlib: it is a Python 2D plotting library that enables users to make publication-quality figures. But, what might be even more convincing is the fact that other packages, such as Pandas, intend to build more plotting integration with Matplotlib as time goes on.

However, what might slow down beginners is the fact that this package is pretty extensive. There is so much that you can do with it and it might be hard to still keep a structure when you're learning how to work with Matplotlib.   

DataCamp has created a Matplotlib cheat sheet for those who might already know how to use the package to their advantage to make beautiful plots in Python, but that still want to keep a one-page reference handy. Of course, for those who don't know how to work with Matplotlib, this might be the extra push be convinced and to finally get started with data visualization in Python. 

You'll see that this cheat sheet presents you with the six basic steps that you can go through to make beautiful plots. 

Check out the infographic by clicking on the button below:

Python Matplotlib cheat sheet

With this handy reference, you'll familiarize yourself in no time with the basics of Matplotlib: you'll learn how you can prepare your data, create a new plot, use some basic plotting routines to your advantage, add customizations to your plots, and save, show and close the plots that you make.

What might have looked difficult before will definitely be more clear once you start using this cheat sheet! Use it in combination with the Matplotlib Gallery, the documentation.

Matplotlib 

Matplotlib is a Python 2D plotting library which produces publication-quality figures in a variety of hardcopy formats and interactive environments across platforms.

Prepare the Data 

1D Data 

>>> import numpy as np
>>> x = np.linspace(0, 10, 100)
>>> y = np.cos(x)
>>> z = np.sin(x)

2D Data or Images 

>>> data = 2 * np.random.random((10, 10))
>>> data2 = 3 * np.random.random((10, 10))
>>> Y, X = np.mgrid[-3:3:100j, -3:3:100j]
>>> U = 1 X** 2 + Y
>>> V = 1 + X Y**2
>>> from matplotlib.cbook import get_sample_data
>>> img = np.load(get_sample_data('axes_grid/bivariate_normal.npy'))

Create Plot

>>> import matplotlib.pyplot as plt

Figure 

>>> fig = plt.figure()
>>> fig2 = plt.figure(figsize=plt.figaspect(2.0))

Axes 

>>> fig.add_axes()
>>> ax1 = fig.add_subplot(221) #row-col-num
>>> ax3 = fig.add_subplot(212)
>>> fig3, axes = plt.subplots(nrows=2,ncols=2)
>>> fig4, axes2 = plt.subplots(ncols=3)

Save Plot 

>>> plt.savefig('foo.png') #Save figures
>>> plt.savefig('foo.png',  transparent=True) #Save transparent figures

Show Plot

>>> plt.show()

Plotting Routines 

1D Data 

>>> fig, ax = plt.subplots()
>>> lines = ax.plot(x,y) #Draw points with lines or markers connecting them
>>> ax.scatter(x,y) #Draw unconnected points, scaled or colored
>>> axes[0,0].bar([1,2,3],[3,4,5]) #Plot vertical rectangles (constant width)
>>> axes[1,0].barh([0.5,1,2.5],[0,1,2]) #Plot horiontal rectangles (constant height)
>>> axes[1,1].axhline(0.45) #Draw a horizontal line across axes
>>> axes[0,1].axvline(0.65) #Draw a vertical line across axes
>>> ax.fill(x,y,color='blue') #Draw filled polygons
>>> ax.fill_between(x,y,color='yellow') #Fill between y values and 0

2D Data 

>>> fig, ax = plt.subplots()
>>> im = ax.imshow(img, #Colormapped or RGB arrays
      cmap= 'gist_earth', 
      interpolation= 'nearest',
      vmin=-2,
      vmax=2)
>>> axes2[0].pcolor(data2) #Pseudocolor plot of 2D array
>>> axes2[0].pcolormesh(data) #Pseudocolor plot of 2D array
>>> CS = plt.contour(Y,X,U) #Plot contours
>>> axes2[2].contourf(data1) #Plot filled contours
>>> axes2[2]= ax.clabel(CS) #Label a contour plot

Vector Fields 

>>> axes[0,1].arrow(0,0,0.5,0.5) #Add an arrow to the axes
>>> axes[1,1].quiver(y,z) #Plot a 2D field of arrows
>>> axes[0,1].streamplot(X,Y,U,V) #Plot a 2D field of arrows

Data Distributions 

>>> ax1.hist(y) #Plot a histogram
>>> ax3.boxplot(y) #Make a box and whisker plot
>>> ax3.violinplot(z)  #Make a violin plot

Plot Anatomy & Workflow 

Plot Anatomy 

 y-axis      

                           x-axis 

Workflow 

The basic steps to creating plots with matplotlib are:

1 Prepare Data
2 Create Plot
3 Plot
4 Customized Plot
5 Save Plot
6 Show Plot

>>> import matplotlib.pyplot as plt
>>> x = [1,2,3,4]  #Step 1
>>> y = [10,20,25,30] 
>>> fig = plt.figure() #Step 2
>>> ax = fig.add_subplot(111) #Step 3
>>> ax.plot(x, y, color= 'lightblue', linewidth=3)  #Step 3, 4
>>> ax.scatter([2,4,6],
          [5,15,25],
          color= 'darkgreen',
          marker= '^' )
>>> ax.set_xlim(1, 6.5)
>>> plt.savefig('foo.png' ) #Step 5
>>> plt.show() #Step 6

Close and Clear 

>>> plt.cla()  #Clear an axis
>>> plt.clf(). #Clear the entire figure
>>> plt.close(). #Close a window

Plotting Customize Plot 

Colors, Color Bars & Color Maps 

>>> plt.plot(x, x, x, x**2, x, x** 3)
>>> ax.plot(x, y, alpha = 0.4)
>>> ax.plot(x, y, c= 'k')
>>> fig.colorbar(im, orientation= 'horizontal')
>>> im = ax.imshow(img,
            cmap= 'seismic' )

Markers 

>>> fig, ax = plt.subplots()
>>> ax.scatter(x,y,marker= ".")
>>> ax.plot(x,y,marker= "o")

Linestyles 

>>> plt.plot(x,y,linewidth=4.0)
>>> plt.plot(x,y,ls= 'solid') 
>>> plt.plot(x,y,ls= '--') 
>>> plt.plot(x,y,'--' ,x**2,y**2,'-.' ) 
>>> plt.setp(lines,color= 'r',linewidth=4.0)

Text & Annotations 

>>> ax.text(1,
           -2.1, 
           'Example Graph', 
            style= 'italic' )
>>> ax.annotate("Sine", 
xy=(8, 0),
xycoords= 'data', 
xytext=(10.5, 0),
textcoords= 'data', 
arrowprops=dict(arrowstyle= "->", 
connectionstyle="arc3"),)

Mathtext 

>>> plt.title(r '$sigma_i=15$', fontsize=20)

Limits, Legends and Layouts 

Limits & Autoscaling 

>>> ax.margins(x=0.0,y=0.1) #Add padding to a plot
>>> ax.axis('equal')  #Set the aspect ratio of the plot to 1
>>> ax.set(xlim=[0,10.5],ylim=[-1.5,1.5])  #Set limits for x-and y-axis
>>> ax.set_xlim(0,10.5) #Set limits for x-axis

Legends 

>>> ax.set(title= 'An Example Axes',  #Set a title and x-and y-axis labels
            ylabel= 'Y-Axis', 
            xlabel= 'X-Axis')
>>> ax.legend(loc= 'best')  #No overlapping plot elements

Ticks 

>>> ax.xaxis.set(ticks=range(1,5),  #Manually set x-ticks
             ticklabels=[3,100, 12,"foo" ])
>>> ax.tick_params(axis= 'y', #Make y-ticks longer and go in and out
             direction= 'inout', 
              length=10)

Subplot Spacing 

>>> fig3.subplots_adjust(wspace=0.5,   #Adjust the spacing between subplots
             hspace=0.3,
             left=0.125,
             right=0.9,
             top=0.9,
             bottom=0.1)
>>> fig.tight_layout() #Fit subplot(s) in to the figure area

Axis Spines 

>>> ax1.spines[ 'top'].set_visible(False) #Make the top axis line for a plot invisible
>>> ax1.spines['bottom' ].set_position(( 'outward',10))  #Move the bottom axis line outward

Have this Cheat Sheet at your fingertips

Original article source at https://www.datacamp.com

#matplotlib #cheatsheet #python

Garry Taylor

Garry Taylor

1653464648

Python Data Visualization: Bokeh Cheat Sheet

A handy cheat sheet for interactive plotting and statistical charts with Bokeh.

Bokeh distinguishes itself from other Python visualization libraries such as Matplotlib or Seaborn in the fact that it is an interactive visualization library that is ideal for anyone who would like to quickly and easily create interactive plots, dashboards, and data applications. 

Bokeh is also known for enabling high-performance visual presentation of large data sets in modern web browsers. 

For data scientists, Bokeh is the ideal tool to build statistical charts quickly and easily; But there are also other advantages, such as the various output options and the fact that you can embed your visualizations in applications. And let's not forget that the wide variety of visualization customization options makes this Python library an indispensable tool for your data science toolbox.

Now, DataCamp has created a Bokeh cheat sheet for those who have already taken the course and that still want a handy one-page reference or for those who need an extra push to get started.

In short, you'll see that this cheat sheet not only presents you with the five steps that you can go through to make beautiful plots but will also introduce you to the basics of statistical charts. 

Python Bokeh Cheat Sheet

In no time, this Bokeh cheat sheet will make you familiar with how you can prepare your data, create a new plot, add renderers for your data with custom visualizations, output your plot and save or show it. And the creation of basic statistical charts will hold no secrets for you any longer. 

Boost your Python data visualizations now with the help of Bokeh! :)


Plotting With Bokeh

The Python interactive visualization library Bokeh enables high-performance visual presentation of large datasets in modern web browsers.

Bokeh's mid-level general-purpose bokeh. plotting interface is centered around two main components: data and glyphs.

The basic steps to creating plots with the bokeh. plotting interface are:

  1. Prepare some data (Python lists, NumPy arrays, Pandas DataFrames and other sequences of values)
  2. Create a new plot
  3. Add renderers for your data, with visual customizations
  4. Specify where to generate the output
  5. Show or save the results
>>> from bokeh.plotting import figure
>>> from bokeh.io import output_file, show
>>> x = [1, 2, 3, 4, 5] #Step 1
>>> y = [6, 7, 2, 4, 5]
>>> p = figure(title="simple line example", #Step 2
x_axis_label='x',
y_axis_label='y')
>>> p.line(x, y, legend="Temp.", line_width=2) #Step 3
>>> output_file("lines.html") #Step 4
>>> show(p) #Step 5

1. Data 

Under the hood, your data is converted to Column Data Sources. You can also do this manually:

>>> import numpy as np
>>> import pandas as pd
>>> df = pd.OataFrame(np.array([[33.9,4,65, 'US'], [32.4, 4, 66, 'Asia'], [21.4, 4, 109, 'Europe']]),
                     columns= ['mpg', 'cyl',   'hp',   'origin'],
                      index=['Toyota', 'Fiat', 'Volvo'])


>>> from bokeh.models import ColumnOataSource
>>> cds_df = ColumnOataSource(df)

2. Plotting 

>>> from bokeh.plotting import figure
>>>p1= figure(plot_width=300, tools='pan,box_zoom')
>>> p2 = figure(plot_width=300, plot_height=300,
x_range=(0, 8), y_range=(0, 8))
>>> p3 = figure()

3. Renderers & Visual Customizations 

Glyphs 

Scatter Markers 
Bokeh Scatter Markers

>>> p1.circle(np.array([1,2,3]), np.array([3,2,1]), fill_color='white')
>>> p2.square(np.array([1.5,3.5,5.5]), [1,4,3],
color='blue', size=1)

Line Glyphs 

Bokeh Line Glyphs

>>> pl.line([1,2,3,4], [3,4,5,6], line_width=2)
>>> p2.multi_line(pd.DataFrame([[1,2,3],[5,6,7]]),
pd.DataFrame([[3,4,5],[3,2,1]]),
color="blue")

Customized Glyphs

Selection and Non-Selection Glyphs 

Selection Glyphs

>>> p = figure(tools='box_select')
>>> p. circle ('mpg', 'cyl', source=cds_df,
selection_color='red',
nonselection_alpha=0.1)

Hover Glyphs

Hover Glyphs

>>> from bokeh.models import HoverTool
>>>hover= HoverTool(tooltips=None, mode='vline')
>>> p3.add_tools(hover)

Color Mapping 

Bokeh Colormapping Glyphs

>>> from bokeh.models import CategoricalColorMapper
>>> color_mapper = CategoricalColorMapper(
             factors= ['US', 'Asia', 'Europe'],
             palette= ['blue', 'red', 'green'])
>>>  p3. circle ('mpg', 'cyl', source=cds_df,
            color=dict(field='origin',
                 transform=color_mapper), legend='Origin')

4. Output & Export 

Notebook

>>> from bokeh.io import output_notebook, show
>>> output_notebook()

HTML 

Standalone HTML 

>>> from bokeh.embed import file_html
>>> from bokeh.resources import CON
>>> html = file_html(p, CON, "my_plot")

>>> from  bokeh.io  import  output_file,  show
>>> output_file('my_bar_chart.html',  mode='cdn')

Components

>>> from bokeh.embed import components
>>> script, div= components(p)

PNG

>>> from bokeh.io import export_png
>>> export_png(p, filename="plot.png")

SVG 

>>> from bokeh.io import export_svgs
>>> p. output_backend = "svg"
>>> export_svgs(p,filename="plot.svg")

Legend Location 

Inside Plot Area 

>>> p.legend.location = 'bottom left'

Outside Plot Area 

>>> from bokeh.models import Legend
>>> r1 = p2.asterisk(np.array([1,2,3]), np.array([3,2,1])
>>> r2 = p2.line([1,2,3,4], [3,4,5,6])
>>> legend = Legend(items=[("One" ,[p1, r1]),("Two",[r2])], location=(0, -30))
>>> p.add_layout(legend, 'right')

Legend Background & Border 

>>> p.legend. border_line_color = "navy"
>>> p.legend.background_fill_color = "white"

Legend Orientation 

>>> p.legend.orientation = "horizontal"
>>> p.legend.orientation = "vertical"

Rows & Columns Layout

Rows

>>> from bokeh.layouts import row
>>>layout= row(p1,p2,p3)

Columns

>>> from bokeh.layouts import columns
>>>layout= column(p1,p2,p3)

Nesting Rows & Columns 

>>>layout= row(column(p1,p2), p3)

Grid Layout 

>>> from bokeh.layouts import gridplot
>>> rowl = [p1,p2]
>>> row2 = [p3]
>>> layout = gridplot([[p1, p2],[p3]])

Tabbed Layout 

>>> from bokeh.models.widgets import Panel, Tabs
>>> tab1 = Panel(child=p1, title="tab1")
>>> tab2 = Panel(child=p2, title="tab2")
>>> layout = Tabs(tabs=[tab1, tab2])

Linked Plots

Linked Axes 

Linked Axes
>>> p2.x_range = p1.x_range
>>> p2.y_range = p1.y_range

Linked Brushing 

>>> p4 = figure(plot_width = 100, tools='box_select,lasso_select')
>>> p4.circle('mpg', 'cyl' , source=cds_df)
>>> p5 = figure(plot_width = 200, tools='box_select,lasso_select')
>>> p5.circle('mpg', 'hp', source=cds df)
>>>layout= row(p4,p5)

5. Show or Save Your Plots  

>>> show(p1)
>>> show(layout)
>>> save(p1)

Have this Cheat Sheet at your fingertips

Original article source at https://www.datacamp.com

#python #datavisualization #bokeh #cheatsheet

Rahim Makhani

Rahim Makhani

1620968589

Get a Bug Free and smooth website with website Maintenance

Having a website for your own firm or business is very important as it can benefit you in many ways like your users can get 24/7 service from your company, you can exchange your information, it can help you to expand your business in the market. One must also maintain their website to keep it bug free and updated.

Your website should be bug free because if there is any bug in your website it will slow down the performance of it and will not even work properly if this happens then there are chances that you may lose your customers.

Are you searching for a company that can provide you with website support and maintenance? Nevina Infotech is the best company that can help you with the maintenance and support, as we have enthusiastic web app developers who can help you to maintain your website.

#website maintenance services #website support and maintenance #website maintenance support #website maintenance packages #website maintenance company #website maintenance plans

Security Website Design

As web developers, we strive to meet your specific needs by creating a website that is user-friendly and remains relevant to the current design trends. This ensures that your website grabs the attention of your audience and keeps you ahead of your competitors.

DataIT Solutions team of experts works collaboratively to create ideas that can meet your requirements. Our Website Designing Company believes in High-Quality Professional Website Designing for your Security Website Designing. Our designers have experience in working on a wide array of projects, including websites of the next generation. We listen to your needs and then deliver.

Our Expertise includes:

  • Dot Net Development
  • PHP Development
  • HTML5 Development
  • IOS App Development
  • Android App Development
  • Website Security services

Our team of experts has the expertise, knowledge, and skills to take control and dominate the web design industry over the next couple of years. They are on hand to listen to your ideas, goals, and help you to have a website that is unique and works with your business and brand.

Looking for a better design? Need a professional web design?
Get in touch with our, Web Design Professional experts.

#security website design #security website designing #security website designer #website designer #website designing #website design