This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wc_show_variable_product_stock_out() | |
{ | |
global $product; | |
if( $product->is_type( 'variable' ) ) | |
{ | |
$args = array( | |
'post_type' => 'product_variation', | |
'post_status' => array( 'private', 'publish' ), | |
'numberposts' => -1, | |
'orderby' => 'menu_order', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Yahoo_Weather | |
{ | |
protected $base_url = "http://query.yahooapis.com/v1/public/yql"; | |
protected $location = false; | |
protected $units = false; | |
protected $current = false; | |
protected $future = false; | |
protected $data = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function diagonalValues($arr) { | |
$d_ar = []; | |
$main_len = count($arr); | |
foreach($arr as $key => $ar) { | |
$sub_len = count($ar); | |
if($main_len != $sub_len) { | |
throw new Exception('Array index count mismatched. Hence this is not square array.'); | |
} | |
$d_ar[0][] = $ar[$key]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function miniMaxSum($arr) { | |
$sum = array_sum($arr); | |
$min = $sum; | |
$max = 0; | |
foreach($arr as $key => $val) { | |
$excluded_sum = $sum - $val; | |
if($max < $excluded_sum) { | |
$max = $excluded_sum; | |
} | |
if($min > $excluded_sum) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Twins($a, $b) { | |
$flag = false; | |
$a_len = count($a); | |
$b_len = count($b); | |
if($a_len != $b_len) { | |
throw new Exception('array index count mismatched!'); | |
} | |
$result = []; | |
for($i = 0; $i<$a_len; $i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("input:empty").length == 0; | |
/* Above statement will bypass the empty spaces. */ | |
/* If you want to search for all empty inputs including blank/empty spaces. Try below one */ | |
$("input").filter(function () { | |
return $.trim($(this).val()).length == 0 | |
}).length == 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will print you PID of process bound on that port. | |
fuser 3000/tcp | |
# And this will kill that process | |
fuser -k 3000/tcp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/***** | |
Here, I am assuming that you have already assigned all variants as tags of a product. Because Shopify filter does not work with variant options. | |
And, if you assigns all variants as tags you can not differentiate them from tags. | |
Here I code that is working for 2 filters Size & Length (with mulitple options. ie mulitple sizes, multiple lengths, etc | |
*****/ | |
<div class="filters-toolbar"> | |
<div class="filters-toolbar__item size-filter"> | |
{% assign variant_sizes = "" %} | |
{% assign variant_lengths = "" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// connect and login to FTP server | |
$ftp_server = "ftp.domain.com"; | |
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server"); | |
//$ftp_conn = ftp_ssl_connect($ftp_server);// for SSL-FTP connection instead of ftp_connect | |
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass); | |
$file = "local-file.jpg"; | |
// upload file | |
if (ftp_put($ftp_conn, "server-file.jpg", $file, FTP_ASCII)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def rotate(self, nums: List[int], k: int) -> None: | |
""" | |
Do not return anything, modify nums in-place instead. | |
""" | |
count = 0 | |
start = 0 | |
while (count < len(nums)): | |
current = start | |
prev = nums[start] |