Skip to content

Instantly share code, notes, and snippets.

@maximzasorin
maximzasorin / chromium-browser.sh
Last active August 29, 2015 14:25
Set dark theme for one Chromium’s window, but not for Ctrl+N windows.
#!/bin/sh
chromium-browser "$@" &
pid=$!
wid=$(wmctrl -lp | grep $pid | cut -c 1-10)
WINREP=""
while [ ! "`echo $WINREP | grep -l 'Chromium'`" ]
do
@maximzasorin
maximzasorin / ajax-deliveries.js
Last active August 29, 2015 14:25
Loading delivery methods for cart on HostCMS
(function($) {
$.extend({
loadDeliveries: function(path) {
var shop_country_id = $('#shop_country_id').val();
var shop_country_location_id = $('#shop_country_location_id').val();
var shop_country_location_city_id = $('#shop_country_location_city_id').val();
$.clientRequest({
path: path + '?ajaxLoad&getDeliveries&shop_country_id=' + shop_country_id
+ '&shop_country_location_id=' + shop_country_location_id
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Task 3</title>
<style>
textarea { width: 400px; height: 200px; }
</style>
</head>
@maximzasorin
maximzasorin / remove-default-route.sh
Created August 5, 2015 19:45
Remove default route, wait for Ctrl+C and restore it
#!/bin/bash
ip route del default
trap ctrl_c INT
function ctrl_c() {
ip route add default via 192.168.1.1
exit
}
@maximzasorin
maximzasorin / simple-shipping-method.php
Last active October 27, 2015 20:11
Simple shipping method for Woocommerce.
<?php
/*
Plugin Name: Simple shipping method
Description: Simple shipping method plugin
Version: 1.0.0
*/
/**
* Check if WooCommerce is active
*/
@maximzasorin
maximzasorin / transfer_images.php
Last active October 30, 2015 07:10
Transfer image from one object to other for HostCMS
<?php
class SomeTransferClass {
// ...
private function _transferImages($sourceObject, $destObject)
{
if (is_file($sourceObject->getLargeFilePath()))
{
@maximzasorin
maximzasorin / transfer_infromationsystem_items.php
Created October 30, 2015 09:46
Transfer informationsystem items to shop group / Перенос элементов ИС в группу магазина (HostCMS)
<?php
class TransferItems {
// private $_propertyDir = 5;
private $_propertyDir = 0;
private $_informationsystem = 57;
private $_shopGroupId = 12012;
private $_transferedItems = 0;
@maximzasorin
maximzasorin / transfer_shop_items.php
Last active October 30, 2015 09:46
Transfer shop items from one shop to group in another shop / Перенос товаров одного магазина в группу другого (HostCMS)
<?php
class TransferShopItems
{
private $_propertyDir = 0;
private $_sourceShop = 5;
private $_destShopGroup = 12591;
private $_transferedItems = 0;
public function makeTransfer()
wget -q -r -l 5 -O - $1 | grep -E -o "\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+\b"
@maximzasorin
maximzasorin / choose-first-location.php
Created November 6, 2015 08:38
Выбор первой области по умолчанию при оформлении заказа (HostCMS)
<?php
$oShopCountry = Core_Entity::factory('shop_country', $oShop->shop_country_id);
if ($oShopCountry)
{
$aoShopCountryLocations = $oShopCountry
->Shop_Country_Locations
->findAll();