Skip to content

Instantly share code, notes, and snippets.

View Insolita's full-sized avatar
🤪

Insolita Insolita

🤪
View GitHub Profile
@Insolita
Insolita / pgsql_fts_usage.php
Last active January 28, 2017 06:34
Полнотекстовый поиск postgres+yii2 - использование
<?php
//--------------------------------------
/**
* @param string $query
*
* @return string
*/
public function prepareQuery(string $query):string
{
$query = array_filter(explode(' ', mb_strtolower($query)), 'trim');
@Insolita
Insolita / gist:8d1e5cdf5d9e48ac81698fc63d2ad07a
Created January 28, 2017 06:32
yii2 profiling helper for console/test environment
<?php
namespace common\tests;
use Codeception\Util\Debug;
use yii\console\Application;
use yii\db\ActiveQuery;
use yii\db\Connection;
use yii\helpers\ArrayHelper;
use yii\helpers\Console;
use yii\helpers\VarDumper;
@Insolita
Insolita / pybrowser.py
Created March 16, 2017 07:56 — forked from kklimonda/pybrowser.py
A minimal Gtk+/Webkit based browser in Python
import sys
from gi.repository import Gtk, Gdk, WebKit
class BrowserTab(Gtk.VBox):
def __init__(self, *args, **kwargs):
super(BrowserTab, self).__init__(*args, **kwargs)
go_button = Gtk.Button("go to...")
go_button.connect("clicked", self._load_url)
self.url_bar = Gtk.Entry()
<?php
namespace console\components\queue;
use yii\base\Object;
use zhuravljov\yii\queue\Job;
/**
* Class ComplexJob
*
* @package console\components
@Insolita
Insolita / MyTwiggedView.php
Last active May 31, 2017 18:33
MyTwiggedView
'view'=>[
'class'=>\yii\web\View::class,
'defaultExtension' => 'twig',
'renderers' => [
'twig'=>[
'class'=>\yii\twig\ViewRenderer::class,
'cachePath' => '@app/runtime/Twig/cache',
'options' => [
'auto_reload' => true,
],
@Insolita
Insolita / BaseFilterRequest.php
Last active April 23, 2019 12:37
Laravel grid
<?php
/**BaseRequest class for grid request **/
class BaseFilterRequest extends FormRequest
{
const SORT_ASC = 'asc';
const SORT_DESC = 'desc';
public static $sortable
= [
'id',
mind=d=>{S=storage,T=d.infection,U=d.john.position,V=d.nexa.position,S.f=S.f||0,S.n=S.n||0,l='left',r='right',u='up',w='down';A=v=>Math.abs(v);B=v=>v.length;C=v=>(U.x==v.x&&D(v))||(U.y==v.y&&E(v));D=v=>A(U.y-v.y)==1;E=v=>A(U.x-v.x)==1;F=(x,y)=>U.x!=x?(U.x>x?l:r):(U.y>y?u:w);G=(x,y)=>U.y!=y?(U.y>y?u:w):(U.x>x?l:r);H=()=>T.some(v=>U.x==v.x&&U.y==v.y);I=(x,y)=>(!J()&&!S.f)?G(x,y):F(x,y);J=()=>{if(U.x==V.x&&U.y==V.y){S.n+=1;}return(S.n>0);};K=()=>U.x==V.x;L=v=>v.reduce((r,t)=>(!B(r)?(r=T.filter(t), r):r),[]);M=v=>B(v)?v[0]:[];N=()=>T.reduce((m,t)=>{d=O(V,t);if(m.d<d){m.d=d;m.c=t;}return m;},{'d':0,'c':S.t});O=(v,t)=>A(v.x-t.x)+A(v.y-t.y);P=()=>{S.t=(!S.f?T[0]:(S.f&&!J()?V:(S.t&&V.y!=1?N().c:(Z=L([C,(v)=>(U.y==v.y),D]),B(Z)?M(Z):N().c))));return I(S.t.x,S.t.y)};Q=()=>H()&&!(!J()&&K())?(S.t=null,S.f=1,1):0;return Q()?'cure':P()}
@Insolita
Insolita / firstvds_full.js
Created December 8, 2017 17:39
firstvds_full.js
let mind=(D)=>{
let my = D.john.position,nx = D.nexa.position,inf=D.infection;
storage.firstGoal = storage.firstGoal||0;
storage.nexa_catch=storage.nexa_catch||0;
let A = v => Math.abs(v);
let B = v => v.length;
let nearOneStep = (it) =>((my.x === it.x && nearNextRowY(it)) || (my.y === it.y && nearNextRowX(it)));
let nearNextRowY = (it) => (A(my.y-it.y)===1);
let nearNextRowX = (it) => (A(my.x-it.x)===1);
let directionByX = (x, y)=> (my.x !== x)? (my.x > x ? 'left' : 'right') :(my.y > y ? 'up' : 'down');
@Insolita
Insolita / Envoy.blade.php
Created April 9, 2018 11:35 — forked from michaeldyrynda/Envoy.blade.php
Laravel 5 Envoy deploy configuration
@servers([ 'remote' => 'server.example.com', ])
@setup
if ( ! isset($repo) )
{
throw new Exception('--repo must be specified');
}
if ( ! isset($base_dir) )
{
@Insolita
Insolita / DummyJob.php
Last active May 29, 2018 11:34
Task App Article
<?php
namespace App\Jobs;
class DummyJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private $params;
public function __construct(array $params = [])
{
$this->params = $params;