Python - Difference Between is and double equals

Python – Difference Between “is” and “==” (double equals)

This may be a point where a lot of you may get confused. I see some people using them in if conditions without actually knowing what they do. Let me try to explain the concept with a couple of lines of code…

See the code below and try to guess what is printed as the output:

Here is the output:

Explanation:

1- “==” will check if the contents of the lists are the same, including the order.

2- “is” will check if the lists are the same list. Meaning the exact same list in the memory!

3- “list4 = list1” makes list4 point to the same list as list1 in the memory. If we edit list1 and print list4 we will get the same result as we were printing list1.

 

Difference between window.onload and $(document).ready()

Do you think $(document).ready() and window.onload are the same thing? Do you use one for the other? Do you use them interchangeably? If you do so, you are wrong. $(document).ready() and window.onload are not the same thing.

What did you think? They both get triggered when the page is loaded? They get triggered when the DOM is loaded?

The fact is they get triggered at different points in the page lifecycle.

$(document).ready() -> gets triggered when the DOM is loaded

window.onload -> gets triggered when the page is loaded with all the content like images, iframes etc.

Yes, they may sometimes get triggered almost at the same time if your page is only composed of DOM elements, but most of the time they will get triggered at different times, window.onload being triggered later.

Hope this helps.
Good Luck,
Serdar

Katacoda

This is a micro post.

I would like to mention an eLearning platform for tech/dev people who might be interested.

Katacoda is an inteactive learning platform for software developers, engineers and anybody who likes this stuff.. They have scenario-based learning activities designed for an optimum learning pattern. Currently, they have learning activities available that are related to some trending topics that might interest many of you. Some examples are:

  • Docker & Containers
  • Kubernetes
  • Docker Swarm Mode
  • CI/CD with Jenkins
  • Load balance containers using Traefik

Their Twitter account says they are London-based and their first tweet is posted on 27 Jul 2015. Seems like they are almost 2 years old but yesterday was the first time I heard about them. Sorry guys 🙂

Hope this helps.
Good Luck,
Serdar

Linking Jenkins to a Local Git Repository

I wanted to try creating a CI (continuous integration) pipeline using Jenkins at home for fun 🙂

I launched IntelliJ IDEA by jetbrains and created an empty test project. Then I added this project to Git. In case you don’t know how, below is how you can create a Git repository for you project in IntelliJ IDEA (Community 2017.1.2).

intellij-idea-create-git-repository

Once the Git repository has been successfully created you should see a .git folder as below (You may need to enable display of hidden folders).

.git folder

Now, launch Jenkins (by default it should launch on http://localhost:8080/).

Now click on New Item, select “Freestyle project” and type a name for it, click OK.

jenkins new item

 

jenkins freestyle project

Go to Source Code Management tab and select Git

jenkins source code management tab

The critical part is what you enter here as the “Repository URL”. The correct value should start with file://// for a local repository which is created on your PCs local file system.

For a test project which was created under “Users/serdarosmanonur/IdeaProjects/JavaProject” the Repository URL should be entered as “file:////Users/serdarosmanonur/IdeaProjects/JavaProject”.

Now save this configuration, go to “Jenkins” dashboard (http://localhost:8080/) and click your projects name on the right.

jenkins dashboard

Click “Build Now” on the left. You should see the build success entry on the Build History area below the Build Now button.

jenkins build project

You have successfully linked Jenkins to your local Git repository and completed your first build.

Hope this helps.
Good Luck,
Serdar

asana for task management

Asana for Task Management

Have you tried Asana? We did and we liked it…

When you are just starting a new project you may not always have all the tools at your disposal. Sometimes it takes time to acquire them tools. Tools like JIRA. Especially if you are working for a big IT company where things may go slow due to some protocols that need to be followed and countless approval processes. Or, even if you have the tools, you might want to do some off the record R&D jobs in parallel and you may not wish to follow them along with the other project tasks inside JIRA (or TFS or whatever). This is where the ASANA comes in.

With Asana, you can create projects, under them you can create tasks, and under the tasks, you can create related subtasks. You can set a due date for the tasks and keep your colleagues notified. With the Asana mobile app and notifications, tracking the tasks’ status really gets fast and efficient.

 

Hope this helps.
Good Luck,
Serdar

css-box-model

What is CSS Box Model?

In DOM (Document Object Model) each element is represented as a rectangular box. These boxes determine the properties like size, color etc. The position of these elements is also determined by these boxes which in turn forms the layout of your webpages. You must know the CSS box model as you know your name if you want to be able to set the layout of your webpages and write your own CSS stylesheets.

The CSS Box Model is the foundation of this layout. It defines 4 basic properties:

–  Content: Content area is defined using “width” and “height” properties

–  Padding: Represents the inner margin of a CSS box

–  Border: A distinct layer, between the outer edge of the padding and the inner edge of the margin

–  Margin: Extends the border area with an empty area used to separate the element from its neighbors

The diagram below explains the concept better:

css-box-model

Hope this helps.
Good Luck,
Serdar

javabeans

What is a Java Bean? Is it Just Any Java Class?

What is a Java Bean? Is it just any java class?

The answer is no!

Many people think when they say “Java Bean” they are talking about just any java class, but this is not the case. A Bean is not just any java class. Java Beans are classes that need to abide by some certain rules/conventions.

3 conventions they should satisfy can be listed as below:

1- They need to have a no-argument public constructor

2- They need to have get/set methods for their properties named according to naming conventions (getProperty, setProperty)

3- They need to be serializable

Hope this helps.
Good Luck,
Serdar

Difference Between URI, URL and URN

What is a URI?

URI (Uniform Resource Identifier) is a series of characters to identify a resource. It has the following format:

scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]

Here the “scheme” is mistaken for protocols. Schemes are not protocols. Many schemes have been designed to work with protocols, yes, bu it is not true for all schemes. Scheme part tells us how the read and interpret the rest of the identifier string.

file://usr/share/doc

The example above has the scheme “file”, and there is no “file” protocol as you know. File scheme is typically used to retrieve files from within one’s own computer.

Not all parts of the URI format defined above are mandatory. Below are the optional parts of a URI:

-User information
-Port
-Query
-Fragment

What is a URL?

Uniform Resource Locator is a special type of URI. Which means URLs are actually URIs. A URL points to a resource on the web. While doing that, a URL tells us where the resource is and which mechanism to use to access it (protocol).

What is a URN?

A URN (Uniform Resource Name) is a special type of URI just like a URL. URNs define a unique resource in the context of a namespace, they don’t tell anything about the location or the access mechanism for this resource.

Below are 2 sample URIs from Wikipedia:

 

bitnami-godaddy

How to Remove Bitnami Banner from Your Discourse Forum Site on GoDaddy

I recently created a cloud server instance on GoDaddy and installed a Bitnami application (Discourse) on it for one of my domains. Then I realized this Bitnami banner on the lower right corner. After some research and trials, I was able to remove this banner from my Discourse forum site. Here is how you can remove Bitnami banner from your website or web application on GoDaddy.

Click Manage next to Cloud Servers

Click Actions and Manage Server

Now click Console and click Connect

If you can’t see the console load, click Console and click Reconnect

Once connected go to /apps/your_app_name in this case /apps/discourse

Type “ls” and hit enter. You will see the bnconfig daemon listed

Now type the command below and hit enter. Bitnami banner will be gone from your website/ web application. In this case from your Discourse forum software.

Hope this helps.
Good Luck,
Serdar

how kerberos works

How Kerberos Works

Kerberos is a computer network authentication protocol that was developed by MIT. An open source, free implementation is available from MIT as well as commercial implementations from other vendors. Kerberos is the native authentication protocol in Active Directory.

Here is how the protocol works:

how kerberos works

In Kerberos, there is no communication between the resource (server) and the KDC. Client takes on the majority of the processing burden in Kerberos, which distributes the authentication workload across the network.

1- Client attempts to log on to the network

Client constructs and authenticator. This includes day and time data, so the authenticators are valid for only a certain period of time. So, they can’t be captured and re-used by an attacker. Some portion of the authenticator is un-encrypted (like who the client is) and some portion of it is encrypted using the client’s key. Kerberos does not transmit your password(key) across the network, password is used as shared secret.

2- KDC receives the authenticator from the client. It tries to decrypt the authenticator with the password it has (KDC has) for that user. If it can’t decrypt the authenticator this means this user (client) is not who they say they are. If it can be decrypted this means the user is who he claims to be and has the correct password.

3- KDC creates a TGT (Ticket Granting Ticket) for the client. This TGT includes the user information and is encrypted by KDC’s own key that only KDC knows about. This TGT is transmitted back to the client and saved on the client machine inside Kerberos Tray. This area is always in the memory and can’t be swapped out to the disk which means If the client computer crashes, this information will be lost. Now the client is logged on and ready to go.

4- Now client computer looks at the Kerberos Tray and sees there is no ticket for the server (resource). Now client sends the TGT back to the KDC and says “I need a ticket for the server”. KDC uses his key to decrypt the TGT. If it can be decrypted then KDC know that this information was generated by him previously. TGTs are generally valid for 8 hours so that KDC will get to re-validate the users but this doesn’t happen every time to save effort. Since KDC was able to decrypt the TGT, now it generates a ticket for the client. This ticket is generated by the server’s key (the resource that client is trying to access) and sent to the client. This ticket is also stored in Kerberos Tray.

5- Now, anytime the client needs to access the server, a copy of this ticket is sent to the server. Server tries to decrypt this ticket with his own key. If it can be decrypted then server knows that this information was generated by the KDC because it is the only other node that knows about server’s password which means this is a legitimate ticket. Once the server decrypts the user information (username, roles, groups etc.) he decides which content client can access. This tickets are not stored in server’s memory. Every time client needs access, he needs to re-send this ticket to the server. Considering how many users the server could be serving to, it makes sense not to store all this ticked data in server’s memory.

 

Hope this helps.
Good Luck,
Serdar