Posts

Search my gist

 

Run a python scripts in web browser using PythonCGI

Image
Hello everyone πŸ˜€   today I want to share another interesting topic which is python CGI. CGI stands for the Common Gateway Interface. This interface allows a web browser to pass input to Python scripts and pass the output of Python scripts to a web browser. Building a web interface is similar to building a graphical user interface. We will run our demonstrations on a Mac OS X computer. Apache is already installed on Mac OS X, launch Safari with http://localhost/ to verify. To enable web sharing, select Sharing from the System Preferences. Instead of public_html , the Sites the directory is where Mac users store their web pages. Instead of /var/www/cgi-bin , CGI scripts are in /Library/WebServer/CGI-Executables . CGI = Common Gateway Interface is a set of protocols through which applications interact with web servers. Apache Configuration To check the version of Apache, we can type the following at the command prompt in a terminal window: httpd -v To launch Apache, type sudo ...

Reverse LL (Iterative)

Given a linked list, reverse it iteratively. You don't need to print the elements, just reverse the LL duplicates and return the head of updated LL. Input format : Linked list elements (separated by space and terminated by -1) ` Sample Input 1 : 1 2 3 4 5 -1 Sample Output 1 : 5 4 3 2 1

Length of LL (recursive)

  Given a linked list, find and return the length of input LL recursively. Input format : Linked list elements (separated by space and terminated by -1) Output format : Length of LL Sample Input : 3 4 5 2 6 1 9 -1 Sample Output : 7

Code : Merge Sort

Given a singly linked list of integers, sort it using 'Merge Sort.' Note : No need to print the list, it has already been taken care. Only return the new head to the list. Input format : The first line contains an Integer 't' which denotes the number of test cases or queries to be run. Then the test cases follow. The first and the only line of each test case or query contains the elements of the singly linked list separated by a single space. Remember/Consider : While specifying the list elements for input, -1 indicates the end of the singly linked list and hence, would never be a list element Output format : For each test case/query, print the elements of the sorted singly linked list. Output for every test case will be printed in a seperate line. Constraints : 1 <= t <= 10^2 0 <= M <= 10^5 Where M is the size of the singly linked list. Time Limit: 1sec Sample Input 1 : 1 10 9 8 7 6 5 4 3 -1 Sample Output 1 : 3 4 5 6 7 8 9 10  Sample Output 2 : 2 -1 10...

Code : Merge two sorted LL

You have been given two sorted(in ascending order) singly-linked lists of integers. Write a function to merge them in such a way that the resulting singly linked list is also sorted(in ascending order) and return the new head to the list. Note : Try solving this in O(1) auxiliary space. No need to print the list, it has already been taken care. Input format : The first line contains an Integer 't' which denotes the number of test cases or queries to be run. Then the test cases follow. The first line of each test case or query contains the elements of the first sorted singly linked list separated by a single space. The second line of the input contains the elements of the second sorted singly linked list separated by a single space. Remember/Consider : While specifying the list elements for input, -1 indicates the end of the singly linked list and hence, would never be a list element Output : For each test case/query, print the resulting sorted singly linked list, separated...

Midpoint of Linked list

  For a given singly linked list of integers, find and return the node present at the middle of the list. Note : If the length of the singly linked list is even, then return the first middle node. Example: Consider, 10 -> 20 -> 30 -> 40 is the given list, then the nodes present at the middle with respective data values are, 20 and 30. We return the first node with data 20.  Input format : The first line contains an Integer 't' which denotes the number of test cases or queries to be run. Then the test cases follow. The first and the only line of each test case or query contains the elements of the singly linked list separated by a single space. Remember/Consider : While specifying the list elements for input, -1 indicates the end of the singly linked list and hence, would never be a list element  Output Format : For each test case/query, print the data value of the node at the middle of the given list. Output for every test case will be printed in a seperate l...

Popular posts from this blog

MySQL Multi Source Master Slave Replication using GTID

Setting Up PostgreSQL Logical Replication with Docker Compose

Regex 101: An Introduction to Regular Expressions for Developers