Skip to content

Instantly share code, notes, and snippets.

@reinislejnieks
reinislejnieks / var_dump_limits.php
Created September 18, 2018 13:18
php increase var_dump limits in script
<?php
ini_set('xdebug.var_display_max_depth', 10);
ini_set('xdebug.var_display_max_children', 500);
ini_set('xdebug.var_display_max_data', 2000);
@reinislejnieks
reinislejnieks / git.md
Last active October 2, 2018 08:39
#git usefull

Remove unstaged changes in all tracked files.

git checkout -- .

Remove unstaged changes in one file.

` git checkout -- [filepath]

@reinislejnieks
reinislejnieks / Laravel-Container.md
Created August 26, 2018 10:44
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
class UserRegistrationTest extends TestCase
{
public function tearDown()
@reinislejnieks
reinislejnieks / camel_case_functions.php
Last active August 23, 2018 20:32
Here are two PHP functions to convert strings between underscore format and camel case
<?php
/**
* Translates a camel case string into a string with
* underscores (e.g. firstName -> first_name)
*
* @param string $str String in camel case format
* @return string $str Translated into underscore format
*/
function fromCamelCase($str) {
$str[0] = strtolower($str[0]);
<?php
/**
* Класс работы с сессиями
*
* Использование
* session::getInstance()->start();
* dump(session::getInstance()->get('qwer'));
* session::getInstance()->set('qwer', 'qwer');
* 1 параметр $key - наименование сессии
* 2 параметр $value - значени сессии
@reinislejnieks
reinislejnieks / learn-oop.md
Created August 19, 2018 12:16 — forked from igor822/learn-oop.md
Learn OOP with PHP
<?php
function file_get_mime($filename) {
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$mimes = array(
'audio/mp4' => 'm4a|f4a|f4b',
'audio/ogg' => 'oga|ogg',
'audio/&' => 'mid|midi|mp3|wav',
'application/javascript' => 'js|jsonp',
/*
Indexes are best used on columns that are frequently used in where clauses, and in any kind of sorting, such as "order by".
If we assign ID as a primary key, we don't need one there.
*/
CREATE INDEX tablename_columnname_idx
ON tablename (columnname)
@reinislejnieks
reinislejnieks / macos.txt
Created April 10, 2018 17:50
#macos split files in folders
i=0;
for f in *;
do
d=dir_$(printf %03d $((i/100+1)));
mkdir -p $d;
mv "$f" $d;
let i++;
done