Skip to content

Instantly share code, notes, and snippets.

View hsali's full-sized avatar

Hafiz Shehbaz Ali hsali

View GitHub Profile
@hsali
hsali / create_subdomain_cpanel.php
Created March 24, 2017 13:32
PHP Script to create subdomain on cpanel .
function create_subdomain($subDomain,$cPanelUser,$cPanelPass,$rootDomain) {
// $buildRequest = "/frontend/x3/subdomain/doadddomain.html?rootdomain=" . $rootDomain . "&domain=" . $subDomain;
$buildRequest = "/frontend/x3/subdomain/doadddomain.html?rootdomain=" . $rootDomain . "&domain=" . $subDomain . "&dir=public_html/subdomains/" . $subDomain;
$openSocket = fsockopen('localhost',2082);
if(!$openSocket) {
return "Socket error";
exit();
import os
from bs4 import BeautifulSoup
import requests
import wget
import pandas as pd
from requests.compat import urljoin
import tqdm
url = "https://towardsdatascience.com/springer-has-released-65-machine-learning-and-data-books-for-free-961f8181f189"
folder = "D:/books/SpringerDataScience"
@hsali
hsali / pandas_to_spark.py
Created October 29, 2019 11:47 — forked from zaloogarcia/pandas_to_spark.py
Script for converting Pandas DF to Spark's DF
from pyspark.sql.types import *
# Auxiliar functions
# Pandas Types -> Sparks Types
def equivalent_type(f):
if f == 'datetime64[ns]': return DateType()
elif f == 'int64': return LongType()
elif f == 'int32': return IntegerType()
elif f == 'float64': return FloatType()
else: return StringType()
@hsali
hsali / sql-mongo_comparison.md
Created September 21, 2019 18:30 — forked from aponxi/sql-mongo_comparison.md
MongoDb Cheat Sheets

SQL to MongoDB Mapping Chart

SQL to MongoDB Mapping Chart

In addition to the charts that follow, you might want to consider the Frequently Asked Questions section for a selection of common questions about MongoDB.

Executables

The following table presents the MySQL/Oracle executables and the corresponding MongoDB executables.

@hsali
hsali / playing_random_audio_file.sh
Created November 15, 2016 18:18
Play random audio files from command line. It is mplayer which will play music command line.
#!/bin/bash
if [ "$1" = "" ]; then
echo "no directory defined!"
exit
fi
if [ "$2" = "" ]; then
echo "no file extension defined!"
@hsali
hsali / my.cong
Created September 29, 2018 21:52
erpnext maria db configuration
#at bottom of my.conf
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql]
default-character-set = utf8mb4
@hsali
hsali / javascript_scapper.js
Created June 7, 2018 10:27
convert HTML select element key values to constant property of PHP Class with comments
art = document.querySelectorAll("#your-select-element-id-here option");
function tag_g(tag_name, tag_value){
clean_name = tag_name.replace('-'," ");
clean_name = clean_name.replace('&',"AND");
clean_name = clean_name.replace(/\s\s+/g, ' ');
clean_name = clean_name.replace(/[^a-zA-Z ]/g, " ");
tag_slug = clean_name.toUpperCase().split(" ").join("_");
tag_str ="\
/** \n \
chrome.webRequest.onHeadersReceived.addListener(
function (details) {
for (var i = 0; i < details.responseHeaders.length; ++i) {
if (details.responseHeaders[i].name.toLowerCase() == 'x-frame-options') {
details.responseHeaders.splice(i, 1);
return {
responseHeaders: details.responseHeaders
};
}
}
@hsali
hsali / hello.py
Created December 22, 2017 18:29
Python Hello World Application
def hello_function():
print "Hello World"
# This is comment.
# calling function
hello_function()
@hsali
hsali / datatables.php
Created July 14, 2017 16:03
datables file which is located in config/datatables.php
<?php
return [
/**
* DataTables search options.
*/
'search' => [
/**
* Smart search will enclose search keyword with wildcard string "%keyword%".
* SQL: column LIKE "%keyword%"