Skip to content

Instantly share code, notes, and snippets.

View hussnainsheikh's full-sized avatar

Sheikh Hussnain hussnainsheikh

View GitHub Profile
hussnainsheikh / random_numbers.php
Created December 1, 2023 00:12
Recursion to generate random numbers within range with no duplicate
/** generate an array of random
* numbers within given range
function generateRandom($end, $total, $start = 0, $numbers = [])
if(count($numbers) == $total) {
return $numbers;
$number = rand($start, $end);
hussnainsheikh / wordpress_sitemaps.php
Last active October 29, 2022 22:06
Create separate sitemaps in WordPress for all the activated languages in WPML.
function sitemaps() {
/* get all the activated languages in WPML plugin */
$languages = apply_filters( 'wpml_active_languages', NULL, array( 'skip_missing' => 0));
foreach((array)$languages as $lang) {
/* change language */
do_action('wpml_switch_language', $lang['code']);
hussnainsheikh /
Created September 6, 2022 00:07
Rename the *index.html* files in all directories, sub directories and remove the directories and sub directories.
import os
def getListOfFiles(dirName):
# create a list of file and sub directories
# names in the given directory
listOfFile = os.listdir(dirName)
allFiles = list()
# Iterate over all the entries
for entry in listOfFile:
hussnainsheikh /
Created November 25, 2021 01:44
Python code to converts JSON data into CSV. Please change your dict obj according to your JSON data. Keep sharing!
import json
import csv
# Opening JSON file
f = open('productfeed.json')
# returns JSON object as
# a dictionary
data = json.load(f)
hussnainsheikh / delete_older_than.php
Last active November 15, 2023 07:23 — forked from tdebatty/delete_older_than.php
A simple PHP function to delete files older than a given age. **Updated to delete files in subdirectories.**
* A simple function that uses mtime to delete files older than a given age (in seconds)
* Very handy to rotate backup or log files, for example...
* $dir String whhere the files are
* $max_age Int in seconds
* return String[] the list of deleted files
hussnainsheikh / table-liquid.liquid
Last active November 25, 2021 01:45
Shopify: Show product Metafields on Product page in Table
{%- comment -%} Metafields {%- endcomment -%}
{%- if product.metafields.xojson != blank -%} //change "xojson" with your scope of metafields, can be global or something else which you defined while creating them.
<div class="row container" id="Specifications">
<header class="section__header column small-12">
<h3 class="section__title heading h3">Product Attributes</h3>
<div class="row">
<div class="columns medium-6 small-12 tooltip-container">
<table role="presentation" style="width: 80%;background: #fff;border: solid 1px #ddd;margin-bottom: 1.25rem;table-layout: auto;">
hussnainsheikh / Lamp-stack on ubuntu with SSL on apache
Last active August 8, 2020 02:01
Install lamp-stack on Ubuntu with virtual host and SSL with certbot on apache. If you are facing any issue while installing ask me. Thank you!
#install lamp-stack by tasksel
sudo apt update && sudo apt upgrade
sudo apt install tasksel
sudo tasksel install lamp-server
#install phpmyadmin
sudo apt-get install -y phpmyadmin
#create db_user and grant access
hussnainsheikh /
Created October 13, 2019 12:06 — forked from jdhao/
The script will install GCC 5.4.0 on your CentOS 7 system, make sure you have root right. See for more details.
echo "Downloading gcc source files..."
curl -O
echo "extracting files..."
tar xvfj gcc-5.4.0.tar.bz2
echo "Installing dependencies..."
yum install gmp-devel mpfr-devel libmpc-devel -y
echo "Configure and install..."

How to install mysql on ubuntu (which works)

first delete it in case a root password was previously created:

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean

then install it:

hussnainsheikh / Programs.cpp
Last active February 17, 2018 20:44
Simple Problems solution in C++. Please find the comment below for Problem statements.
Program No 1:
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;
int main()