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 / problem_5_part_a.h
Last active September 30, 2019 12:32
Algo Fall 2019 - Mid 1 Problem 5
/*
Following algorithm decides as if a given number M is the median of A or
otherwise. The algorithm outputs either M if M is the median, a number M + 1 if median
is larger than M and the number M – 1 otherwise. Give a tight bound on the running
time of this algorithm
*/
#include <bits/stdc++.h>
using namespace std;
/**
@huzaifaarain
huzaifaarain / problem_4_part_a.h
Last active September 30, 2019 15:15
Algo Fall 2019 - Mid 1 Problem 4
/*
write an algorithm called Count-Values that takes as
input two arrays A and C and then compute value of each counter and store it in array C.
Your algorithm must have ϴ (n) time complexity.
Hint C[ A[i] ] = C[ A[i] ] + 1 might be a useful statement here
*/
#include <bits/stdc++.h>
using namespace std;
/**
@huzaifaarain
huzaifaarain / count_inversions.cpp
Last active September 26, 2019 19:25
DAA Assignment 1 Part 3
// C++ program for Assignment 1 Question 8
// We will count inversions using merge sort algorithm
// and divide and conquer paradigm
#include <bits/stdc++.h>
using namespace std;
long long _mergeSort(long long original_array[], long long arbitrary_array[],
long long left_index, long long right_index);
long long merge(long long original_array[], long long arbitary_array[],
long long left_index, long long mid_index, long long right_index);
@huzaifaarain
huzaifaarain / meta-tags.md
Created May 31, 2019 17:36 — forked from lancejpollard/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@huzaifaarain
huzaifaarain / scrape.py
Created December 24, 2018 05:02
Web Scraping for Email Addresses and Phone numbers using Python
# Small Python Script to scrape websites for
# email addresses and phone numbers(not a very great RE)
# Author: Dhruv Baldawa (@dhruvbaldawa on twitter)
# Github: http://www.github.com/dhruvbaldawa
import urllib,re
f = urllib.urlopen("http://www.example.com")
s = f.read()
re.findall(r"\+\d{2}\s?0?\d{10}",s)
re.findall(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}",s)
@huzaifaarain
huzaifaarain / class-virtualthemedpage-bc.php
Created December 17, 2018 12:53 — forked from brianoz/class-virtualthemedpage-bc.php
WordPress Virtual page with theme
<?php
/*
* Virtual Themed Page class
*
* This class implements virtual pages for a plugin.
*
* It is designed to be included then called for each part of the plugin
* that wants virtual pages.
*
* It supports multiple virtual pages and content generation functions.
@huzaifaarain
huzaifaarain / readme.md
Created December 7, 2018 05:33
dpkg: error: dpkg status database is locked by another process

First run:

lsof /var/lib/dpkg/lock 

Then make sure that process isn't running:

ps cax | grep PID 
@huzaifaarain
huzaifaarain / functions.php
Created December 6, 2018 12:53 — forked from BFTrick/functions.php
WooCommerce add an Empty Cart button
<?php
// check for empty-cart get param to clear the cart
add_action( 'init', 'woocommerce_clear_cart_url' );
function woocommerce_clear_cart_url() {
global $woocommerce;
if ( isset( $_GET['empty-cart'] ) ) {
$woocommerce->cart->empty_cart();
}
}
@huzaifaarain
huzaifaarain / readme.md
Created December 6, 2018 12:49
Get list of all product categories in WooCommerce
$orderby = 'name';
$order = 'asc';
$hide_empty = false ;
$cat_args = array(
    'orderby'    => $orderby,
    'order'      => $order,
    'hide_empty' => $hide_empty,
);
 
@huzaifaarain
huzaifaarain / readme.md
Created December 4, 2018 12:55
What's the difference between git reset --mixed, --soft, and --hard ?

What's the difference between git reset --mixed, --soft, and --hard ?

When you modify a file in your repository, the change is initially unstaged. In order to commit it, you must stage it—that is, add it to the index—using git add. When you make a commit, the changes that are committed are those that have been added to the index.

git reset changes, at minimum, where the current branch (HEAD) is pointing. The difference between --mixed and --soft is whether or not your index is also modified. So, if we're on branch master with this series of commits:

- A - B - C (master)

HEAD points to C and the index matches C.