Skip to content

Instantly share code, notes, and snippets.

View shahzaibkhan's full-sized avatar

Shahzaib Khan shahzaibkhan

View GitHub Profile
@shahzaibkhan
shahzaibkhan / curl.php
Created July 5, 2022 07:18
get_remote_data
<?php
function get_remote_data($url, $post_paramtrs = false) {
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
if ($post_paramtrs) {
curl_setopt($c, CURLOPT_POST, TRUE);
curl_setopt($c, CURLOPT_POSTFIELDS, "var1=bla&" . $post_paramtrs);
} curl_setopt($c, CURLOPT_SSL_VERIFYHOST, false);
<?php
function get_post_views($postID){
$count_key = ‘post_views_count’;
$count = get_post_meta($postID, $count_key, true);
if($count==”){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, ‘0’);
return "0 View";
}
@shahzaibkhan
shahzaibkhan / function.php
Created July 4, 2022 17:17
track_post_views
<?php
function track_post_views ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
global $post;
$post_id = $post->ID;
}
set_post_views($post_id);
}
@shahzaibkhan
shahzaibkhan / functions.php
Last active July 4, 2022 17:16
set_post_views
<?php
// add this code within the function file
function set_post_views($postID) {
$count_key = ‘post_views_count’;
$count = get_post_meta($postID, $count_key, true);
if($count==”){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, ‘0’);
# import the module you’ll use to simulate the computer’s choices:
import random
while True:
# take the user input
user_action = input("Enter a choice (rock, paper, scissors): ")
# Define the possible choices and let the computer choose one of them randomly
possible_actions = ["rock", "paper", "scissors"]
# import the module you’ll use to simulate the computer’s choices:
import random
# take the user input
user_action = input("Enter a choice (rock, paper, scissors): ")
# Define the possible choices and let the computer choose one of them randomly
possible_actions = ["rock", "paper", "scissors"]
computer_action = random.choice(possible_actions)
@shahzaibkhan
shahzaibkhan / functions.php
Created June 30, 2022 04:58
Hide plugins from the WordPressAdmin plugin list
<?php
function plugin_hide() {
global $wp_list_table;
// replace your plugin url here
$hidearr = array('advanced-custom-fields/acf.php');
$myplugins = $wp_list_table->items;
foreach ($myplugins as $key => $val) {
if (in_array($key,$hidearr)) {
unset($wp_list_table->items[$key]);
export const nationalityList = [
'afghan',
'albanian',
'algerian',
'american',
'andorran',
'angolan',
'antiguans',
'argentinean',
'armenian',
@shahzaibkhan
shahzaibkhan / nationality.html
Created June 20, 2022 06:05 — forked from didats/nationality.html
Nationality List in HTML Dropdown
<select name="nationality">
<option value="">-- select one --</option>
<option value="afghan">Afghan</option>
<option value="albanian">Albanian</option>
<option value="algerian">Algerian</option>
<option value="american">American</option>
<option value="andorran">Andorran</option>
<option value="angolan">Angolan</option>
<option value="antiguans">Antiguans</option>
<option value="argentinean">Argentinean</option>
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
ID Year_Birth Education Marital_Status Income Kidhome Teenhome Dt_Customer Recency MntWines MntFruits MntMeatProducts MntFishProducts MntSweetProducts MntGoldProds NumDealsPurchases NumWebPurchases NumCatalogPurchases NumStorePurchases NumWebVisitsMonth AcceptedCmp3 AcceptedCmp4 AcceptedCmp5 AcceptedCmp1 AcceptedCmp2 Complain Z_CostContact Z_Revenue Response
5524 1957 Graduation Single 58138 0 0 04-09-2012 58 635 88 546 172 88 88 3 8 10 4 7 0 0 0 0 0 0 3 11 1
2174 1954 Graduation Single 46344 1 1 08-03-2014 38 11 1 6 2 1 6 2 1 1 2 5 0 0 0 0 0 0 3 11 0
4141 1965 Graduation Together 71613 0 0 21-08-2013 26 426 49 127 111 21 42 1 8 2 10 4 0 0 0 0 0 0 3 11 0
6182 1984 Graduation Together 26646 1 0 10-02-2014 26 11 4 20 10 3 5 2 2 0 4 6 0 0 0 0 0 0 3 11 0
5324 1981 PhD Married 58293 1 0 19-01-2014 94 173 43 118 46 27 15 5 5 3 6 5 0 0 0 0 0 0 3 11 0
7446 1967 Master Together 62513 0 1 09-09-2013 16 520 42 98 0 42 14 2 6 4 10 6 0 0 0 0 0 0 3 11 0
965 1971 Graduation Divorced 55635 0 1 13-11-2012 34 235 65 164 50 49