Skip to content

Instantly share code, notes, and snippets.

View weblegko's full-sized avatar
🏠
Working from home

Dmitry Bednyuk weblegko

🏠
Working from home
View GitHub Profile
@weblegko
weblegko / gist:e8ed29e7ab15bbc4e29adecba2e8aa8d
Last active June 7, 2022 16:01
Prestashop clear statistic from DB
TRUNCATE `ps_connections`;
TRUNCATE `ps_connections_page`;
TRUNCATE `ps_connections_source`;
TRUNCATE `ps_page_viewed`;
TRUNCATE `ps_guest`;
// Setting cookie
// variant 1
$cookie = new Cookie('warehouse');
$cookie->setExpire(time() + 30 * 60);
$cookie->variable_name = 'RU';
//variant 2
$context = Context::getContext();
$context->cookie->__set("mycookie","myvalue");
@weblegko
weblegko / .gitignore
Created June 9, 2020 09:33 — forked from salcode/.gitignore
.gitignore file for a general web project - Bare Minimum Git
# -----------------------------------------------------------------
# .gitignore
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20181206
#
# From the root of your project run
# curl -O https://gist.github.com/salcode/10017553/raw/.gitignore
# to download this file
#
<?php
/**
* Date: 29.07.2019
* Time: 20:49
* hacked by @weblegko
* plugin for slug and many different thubnail creation on file upload
*/
namespace mihaildev\elfinder\plugin;
@weblegko
weblegko / 301redirects.txt
Last active February 21, 2018 10:10
my favorite .htaccess redirects :)
# ---------- склеим - сделаем основным зеркалом без www ---------
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# --------- 301 redirect http -> https ---------
#сначала клием www на без www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule .* http://%1/$0 [L,R=301]
@weblegko
weblegko / wpchangedomain.sql
Created May 5, 2017 07:25
Wordpress, sql sqcript for change domain from phpmyadmin
SET @oldsite='http://oldsite.com';
SET @newsite='http://newsite.com';
UPDATE wp_options SET option_value = replace(option_value, @oldsite, @newsite) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, @oldsite, @newsite);
UPDATE wp_links SET link_url = replace(link_url, @oldsite, @newsite);
UPDATE wp_postmeta SET meta_value = replace(meta_value, @oldsite, @newsite);
/* only uncomment next line if you want all your current posts to post to RSS again as new */
#UPDATE wp_posts SET guid = replace(guid, @oldsite, @newsite);
@weblegko
weblegko / test.scss
Created November 16, 2015 10:42
test
.test{
color: #fff;
background: blue;
box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
@weblegko
weblegko / jquery addClass, removeClass improve
Last active November 4, 2015 16:28
Improve of standart jquery functions: addClass, removeClass. Add delay before execution and addition of callback functions
// Расширим функционал стандартных функций jquery: addClass, removeClass - добавив им timeout и callback
(function() {
var addClass, removeClass;
addClass = $.fn.addClass;
removeClass = $.fn.removeClass;
$.fn.removeClass = function(classNames, timeout, callback) {
if (timeout) {
this.delay(timeout).queue(function() {
removeClass.call($(this), classNames);
if (callback) {
@weblegko
weblegko / sklonenie.js
Created September 30, 2015 13:14
/Функция склонения слов от числа
//Функция склонения слов от числа
//Использовать примерног таким образом: var a = declOfNum(num_persons, ['активный','активных','активных']);
function declOfNum(number, titles)
{
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}