Instantly share code, notes, and snippets.

Saleem Khan saleemkce

  • formerly at Pearson PLC & Ranbas Software
  • Chennai, India
View GitHub Profile

Multi-Threading in PHP with pthreads

A Brief Introduction to Multi-Threading in PHP

  • Foreword
  • Execution
  • Sharing
  • Synchronization
  • Pitfalls
View download_file.php
/*ini settings*/
ini_set('memory_limit', '512M');
$filePath = "G:/Software/versions/..PATH TO DOWNLOAD"; // set your download file path here.
download($filePath); // calls download function
function download($filePath)
View multi-execute-PHP.php
Execute multiple SQL statements in PHP or directly execute .SQL files in MySql using PHP
ini_set('display_errors', 0);
$serverName = 'localhost';
$username = 'root';
$password = '';
View shortest sub-segment finding.php
Given a paragraph of text, write a program to find the first shortest sub-segment that contains each of the given k words at least once. A segment is said to be shorter than other if it contains less number of words.
Ignore characters other than [a-z][A-Z] in the text. Comparison between the strings should be case-insensitive.
If no sub-segment is found then the program should output “NO SUBSEGMENT FOUND”.
Input format :
First line of the input contains the text.
Next line contains k , the number of words given to be searched.
View time-slots computing.php
Given M busy-time slots of N people, You need to print all the available time slots when all the N people can schedule a meeting for a duration of K minutes.
Event time will be of form HH MM ( where 0 <= HH <= 23 and 0 <= MM <= 59 ), K will be in the form minutes.
Input Format:
M K [ M number of busy time slots , K is the duration in minutes ]
Followed by M lines with 4 numbers on each line.
Each line will be of form StartHH StartMM EndHH EndMM [ Example 9Am-11Am time slot will be given as 9 00 11 00 ]
View connected-cli
Given a 2–d matrix , which has only 1’s and 0’s in it. Find the total number of connected sets in that matrix.
Connected set can be defined as group of cell(s) which has 1 mentioned on it and have at least one other cell in that set with which they share the neighbor relationship. A cell with 1 in it and no surrounding neighbor having 1 in it can be considered as a set with one cell in it. Neighbors can be defined as all the cells adjacent to the given cell in 8 possible directions ( i.e N , W , E , S , NE , NW , SE , SW direction ). A cell is not a neighbor of itself.
Input format :
View fibonacci
Given a number K, find the smallest Fibonacci number that shares a common factor( other than 1 ) with it. A number is said to be a common factor of two numbers if it exactly divides both of them.
Output two separate numbers, F and D, where F is the smallest fibonacci number and D is the smallest number other than 1 which divides K and F.
Input Format
First line of the input contains an integer T, the number of testcases.
Then follows T lines, each containing an integer K.