Coding Challenge: Rectangular Intersection

Difficulty: Medium

Problem

Given two rectangles, write a function that can find the rectangular intersection between the two rectangles. The rectangles are always straight and never diagonal (each side is parallel with either the x axis or the y axis). Consider only positive axis.

Rectangular Intersection

The rectangles are defined as a Rectangle class as shown below:

Rectangle(left_x, bottom_y, width, height)

# Example
r = Rectangle(2, 7, 30 8)

Your output rectangle should be returned using this format.

codingchallenges

Coding Challenge: Longest Substring Without Repeating Characters

Difficulty: Easy

Problem

Given a string, find the length of the longest substring without repeating characters.

Examples:

  • Given abcabcbb, the answer is abc, which the length is 3.
  • Given bbbbb, the answer is b, with the length of 1.
  • Given pwwkew, the answer is wke, with the length of 3. Note that the answer must be a substring, pwke is a subsequence and not a substring.
codingchallenges

Custom Log Files With Django and Elastic Beanstalk

With Amazon ElasticBeanstalk it is possible to view log files of your deployed application. However, ElasticBeanstalk by default only returns certain logs like /var/log/httpd/error_log or /var/log/httpd/access_log if you are using Apache httpd.

If you are generating custom logs in your Django application and using file handlers to save them to log files, you will probably want to be able to access and read them easily from the ElasticBeanstalk console.

In this post I will show you how to achieve this, using Django as our backend framework.

django elasticbeanstalk

Making Functions Timeout in Python

Sometimes you need to execute a function that can take a lot of time to finish. You are not sure exactly when the function will finish, but you do not want to wait too long, or let your program “hang” waiting for a response.

We want our function to run for a certain period of time, and if this time limit is exceeded, we want to regain control of the program’s execution.

We can achieve this by using a custom context manager and the signal module from the Python standard library.

Here is a complete example:

python

Dropdown Toolbar Buttons in Netbeans Platform

It is possible to add buttons that toggle a dropdown menu to the main toolbar in your Netbeans Platform application.

For example, the Netbeans IDE Run Project, Debug Project, and Profile Project buttons have a small arrow next to them. When clicked, a dropdown menu with more related actions is shown:

Netbeans IDE Dropdown Buttons

In this article, I will teach you how to implement this behavior.

netbeans platform
Older Posts →