Skip to content

Instantly share code, notes, and snippets.

View huzaifaarain's full-sized avatar
🌎
[email protected]://~ workspace

Muhammad Huzaifa huzaifaarain

🌎
[email protected]://~ workspace
View GitHub Profile
@huzaifaarain
huzaifaarain / fork-example.php
Created April 21, 2021 21:03 — forked from nicksantamaria/fork-example.php
Example: Parallel processing in PHP using pcntl_fork()
<?php
/**
* @file
* Basic demonstration of how to do parallel threads in PHP.
*/
// This array of "tasks" could be anything. For demonstration purposes
// these are just strings, but they could be a callback, class or
// include file (hell, even code-as-a-string to pass to eval()).
@huzaifaarain
huzaifaarain / Readme.md
Last active January 8, 2021 06:26
Delete orphaned, unused files from git

A simple way to detect unused files in a project using git

After finding that we had a few images checked into our project’s repository but that were not referenced in the project, I wanted to write a script to quickly see if there were any other unused assets.

This was a one-off script, so it probably won’t suit everyone’s needs, but here’s how we approached the problem:

First, we needed to get a list of the files that git was tracking in our image directory. While you could use ls for that, I wanted to be sure that we weren’t going to list any files that git was ignoring, so we started with git ls-files, whose output will look something like this if called as git ls-files ./img:

img/foo.png img/bar.png

@huzaifaarain
huzaifaarain / PSR-1.md
Created October 13, 2020 07:51
PHP-FIG PSR Guideline

Basic Coding Standard

This section of the standard comprises what should be considered the standard coding elements that are required to ensure a high level of technical interoperability between shared PHP code.

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119].

name: Problem 1
source code: |-
input: '00#111#000000'
blank: ' '
start state: s1
table:
s1:
0: {R: s2}
'#': {R: s5}
s2:
@huzaifaarain
huzaifaarain / problem_1.cpp
Last active November 3, 2019 20:32
DAA Homework 2 Section C
#include <bits/stdc++.h>
using namespace std;
/**
* Reference Links
* https://www.geeksforgeeks.org/tiling-problem/
**/
long long int MattingTheFloor(int n,long long int dp[]){
if(dp[n] > -1){
return dp[n];
}
@huzaifaarain
huzaifaarain / main.cpp
Last active October 28, 2019 20:15
THIS GIST IS IN DEVELOPMENT MODE, FORK AT YOUR OWN RISK
#include <bits/stdc++.h>
using namespace std;
class Matrix
{
private:
string name;
int rows;
int columns;
int **data;
@huzaifaarain
huzaifaarain / Chomsky Normal Form (CNF) 2.md
Created October 23, 2019 10:57
Chomsky Normal Form (CNF) Definition 2

CSE 322 - Introduction to Formal Methods in Computer Science

Chomsky Normal Form

Dave Bacon
Department of Computer Science & Engineering, University of Washington

A useful form for dealing with context free grammars is the Chomksy normal form. This is a particular form of writing a CFG which is useful for understanding CFGs and for proving things about them. It also makes the parse