Skip to content

Instantly share code, notes, and snippets.

View asvae's full-sized avatar

Yauheni Prakopchyk asvae

View GitHub Profile
# Тестирование cookies в Laravel и phpunit
Бегло пробежавшись глазами по мануалу, может показаться, что вопрос это простой. Но давайте посмотрим на простейший случай.
## Условие
Пользователь вбивает в браузере `register/123` и переходит на страницу. Его редиректит на `register`, выдавая параллельно кукез `referral: 123`. Пользователь регистрируется — реферал должен закрепиться в базе. Нужно протестировать юзкеис.
## Решение 1 (?)
Казалось бы, все просто:
```
$this->visit('register/123')->seeCookie('referral');
@asvae
asvae / Ngrok на среде homestead
Last active April 20, 2017 09:42
Ngrok на среде homestead своими руками
Что такое [Ngrok](https://ngrok.com/)? Не спешите лететь по ссылке. Я сейчас расскажу.
Это своеобразный туннель к локалхосту. Допустим, у вас есть локальный проект, к которому вы обращаетесь следующим образом `http://my-project.local`. Ngrok позволяет другим человекам из интернета открыть ту же страницу, забив адрес `http://my-project.ngrok.com`.
Первый и главный вопрос:
Нафига оно нужно?
===========
1) Очень легко и просто показать заказчику полуфабрикат/прототип, и даже поправить что-нибудь на ходу.
2) Полезно для совместной разработки.
3) Можно хостить что-нибудь мелкое (извращение).
@asvae
asvae / laravel-custom-fluent-json-response.php
Last active March 6, 2016 18:19
Laravel: custom fluent json response
<?php
use Illuminate\Http\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
class ApiJsonResponse extends JsonResponse
{
protected $apiData;
@asvae
asvae / df.vk.sticky.txt
Last active May 13, 2016 06:59
Dwarf fortress vk group menu sticky post
Инструкция по обновлению шапки в группе.
1) Удалить прошлый пост
2) Создать новый от имени группы.
3) Написать `Released Dwarf Fortress 0.40.20`, не забыть изменить версию на актуальную.
4) Вставить ссылки, подождать пока контакт спарсит содержимое:
https://vk.com/page-2606586_49490739
https://pp.vk.me/c624419/v624419143/a20b/dqJyc8wYZL4.jpg
@asvae
asvae / mysql 5.7 importer.php
Created May 3, 2016 18:18
fix db for mysql 5.7 import
<?php
set_time_limit ( 900000 );
$file = fopen('99board.sql', 'r+');
$i = 0;
// SET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
fputs($file, 'SET SESSION sql_mode = \'ONLY_FULL_GROUP_BY,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\';' . PHP_EOL . '/*');
@asvae
asvae / gist:801378550cb4310a6390c65806142aec
Created May 23, 2016 14:27
Baldr sky manual converter
<?php
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
require_once($_SERVER["DOCUMENT_ROOT"] . '/autoload/bootstrap.php');
$path = 'baldr_sky_manual/manual';
$dir = new Filesystem(new Local($_SERVER["DOCUMENT_ROOT"]));
@asvae
asvae / ajax-select.html
Created June 19, 2016 22:44
ajax-select.html
<style>
</style>
<template>
<div>
<!-- Displays selected item only
after click on multiselect, then out of it.-->
<multiselect
:options.sync="options"
@asvae
asvae / vue-multiselect-typeahead
Created July 8, 2016 15:52
vue-multiselect-typeahead
<template>
<div class="ajax-select" :class="{'default': ! isTouched}">
<multiselect
:options="options"
:selected.sync="selected"
:multiple="false"
:placeholder="placeholder"
:on-search-change="fetchData"
key=""
:label="label"
@asvae
asvae / infinite-scroll.vue
Created July 20, 2016 18:29
vue.js infinite scroll component WIP
<template>
<div>
<pre v-text="$data | json"></pre>
</div>
</template>
<script>
export default {
data (){
return {
@asvae
asvae / compare_laravel_and_doctrine_migrations.md
Last active November 13, 2020 18:43
Compare laravel and doctrine migrations

Let’s compare Laravel and Doctrine migrations

Laravel vs Doctrine

This article is targeted on Laravel beginners. No skills required whatsoever. Article is a tad opinionated, so take it with a grain of salt. Also, details are omitted for the sake of brevity.

In this article I will do the actual comparison as well as give several hints to get started.

If you’ve never heard of Doctrine, it is database abstraction layer. Sorta like Eloquent, but different type: Laravel is active record (AR), while Doctrine is object relational mapper (ORM).

Laravel migrations (docs)