Skip to content

Instantly share code, notes, and snippets.

@devig
devig / Price.php
Created March 3, 2019 16:39
laravel artisan make:command
<?php
//php artisan make:command Price
//php artisan price:update p1 param2 array_param1 array_param2 --queue
namespace App\Console\Commands;
use Illuminate\Console\Command;
class Price extends Command
{
@devig
devig / error.php
Created May 5, 2019 19:40
Не логировать E_NOTICE в opencart
class ControllerStartupError extends Controller {
public function index() {
$this->registry->set('log', new Log($this->config->get('config_error_filename')));
set_error_handler(array($this, 'handler'));
//error_reporting(E_ALL & ~E_NOTICE);
//set_error_handler(array($this, 'handler'),E_ALL & ~E_NOTICE); //E_ERROR | E_WARNING | E_USER_WARNING);//просто игнорировать NOTICE
}
public function handler($code, $message, $file, $line) {
@devig
devig / change_price_triggers.sql
Created May 8, 2019 16:45
Триггеры для сортировки без нулевой цены
DROP TRIGGER `products_update_row`;
DROP TRIGGER `products_insert_row`;
DELIMITER ;;
CREATE TRIGGER `products_update_row` BEFORE UPDATE ON `products` FOR EACH ROW
IF NEW.price=0 THEN
SET NEW.`priceon` = 0;
ELSE
SET NEW.`priceon` = 1;
@devig
devig / yml.py
Created May 23, 2019 23:18
yml2csv
# -*- coding: UTF-8 -*-
import pandas as pd
from lxml import etree
import wget
import os
yml_df = pd.DataFrame()
@devig
devig / main.go
Last active August 26, 2019 12:00
weird-faculty
package main
import (
"fmt"
"os"
)
//https://fizzbuzzer.com/weird-faculty/
func main() {
answers := []int{1, 0, 0, 0, 1, 1, 0}
summ := summAnswers(answers) //далее в цикле summ по сути будет friendScore
@devig
devig / main.go
Created August 26, 2019 11:53
Filter countries
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"strconv"
)
@devig
devig / dump.sql
Created September 29, 2019 15:27
GORM
-- Adminer 4.2.5 MySQL dump
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
@devig
devig / unit-of-work.php
Created November 1, 2019 15:18 — forked from voronkovich/unit-of-work.php
Unit of work example
<?php
class Tweet
{
private $id;
private $content;
public function __construct(int $id, string $content)
{
$this->id = $id;
@devig
devig / ngram.php
Last active April 25, 2022 13:57
PHP ngram
<?php
class NGram
{
/**
* The length of the n-gram.
*
* @var int
*/
protected $n;
@devig
devig / .env
Last active November 20, 2019 14:05
Docker php7.3 xdebug phpStorm
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://0.0.0.0:8080
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=db