Skip to content

Instantly share code, notes, and snippets.

@imflexwala
imflexwala / get_combinations.php
Created October 26, 2021 15:20 — forked from cecilemuller/get_combinations.php
PHP: Get all combinations of multiple arrays (preserves keys)
<?php
function get_combinations($arrays) {
$result = array(array());
foreach ($arrays as $property => $property_values) {
$tmp = array();
foreach ($result as $result_item) {
foreach ($property_values as $property_value) {
$tmp[] = array_merge($result_item, array($property => $property_value));
}
/** SSL */
define('FORCE_SSL_ADMIN', true);
// in some setups HTTP_X_FORWARDED_PROTO might contain
// a comma-separated list e.g. http,https
// so check for https existence
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
CREATE OR REPLACE VIEW `cs_inventory_stock_1` AS select distinct `legacy_stock_status`.`product_id` AS `product_id`, `legacy_stock_status`.`website_id` AS `website_id`, `legacy_stock_status`.`stock_id` AS `stock_id`, `legacy_stock_status`.`qty` AS `quantity`, `legacy_stock_status`.`stock_status` AS `is_salable`, `product`.`sku` AS `sku` from ( `cs_cataloginventory_stock_status` as `legacy_stock_status` join `cs_catalog_product_entity` as `product` on (( `legacy_stock_status`.`product_id` = `product`.`entity_id` )))
function printjsonerror(){
switch (json_last_error()) {
case JSON_ERROR_NONE:
echo ' - No errors';
break;
case JSON_ERROR_DEPTH:
echo ' - Maximum stack depth exceeded';
break;
@imflexwala
imflexwala / woocommerce_before_cart_table.php
Last active February 11, 2019 14:30 — forked from bradleysa/gist:7d1448253097784daf94
WooCommerce: Add Continue Shopping Button on Cart Page
<?php
/**
* Add Continue Shopping Button on Cart Page
* Add to theme functions.php file or Code Snippets plugin
*/
add_action( 'woocommerce_before_cart_table', 'woo_add_continue_shopping_button_to_cart' );
function woo_add_continue_shopping_button_to_cart() {
add_filter( 'wp_nav_menu_items', 'add_loginout_link', 1, 2 );
function add_loginout_link( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'main-menu') {
$current_user = wp_get_current_user();
$items .= '<li><a href="'. wp_logout_url( '') .'">Log Out</a></li>';
// $items .= '<li><a style="color: #777777!important; "class="logged_in_user" href="#">Hi, '.$current_user->user_login .'</a></li>';
Error Number: 1054
Unknown column 'aafdas' in 'field list'
SELECT v.vendorTitle, b.vendorBranchName,b.vendorLongitude,b.vendorLatitude,b.vendorWebsite,b.vendorBrief,b.vendorLogoURL,b.vendorTelephone1,b.vendorHoursOfOpration, round(( 6371 * acos( cos( radians( aafdas ) ) * cos( radians( b.vendorLatitude ) ) * cos( radians( b.vendorLongitude ) - radians(19.14513599999998 ) ) + sin( radians( aafdas ) ) * sin( radians( b.vendorLatitude ) ) ) )) AS distance FROM vendor as v JOIN vendor_branch as b ON v.vendorID=b.vendorBranchOf HAVING distance <= 50 ORDER BY distance
Filename: models/Location_model.php
@imflexwala
imflexwala / shell.sh
Created December 8, 2018 17:58
change timestamp using touch
touch -t 201808291217.14 test.txt
<IfModule mod_headers.c>
SetEnvIf Host genr8online.com MAGE_RUN_CODE=genr8_co
SetEnvIf Host genr8online.com MAGE_RUN_TYPE=website
SetEnvIf Host bslim.co.uk MAGE_RUN_CODE=bslim_co
SetEnvIf Host bslim.co.uk MAGE_RUN_TYPE=website
SetEnvIf Host bactiv.co.uk MAGE_RUN_CODE=base
SetEnvIf Host bactiv.co.uk MAGE_RUN_TYPE=website
</IfModule>