Skip to content

Instantly share code, notes, and snippets.

View Ellrion's full-sized avatar

Maksim (Ellrion) Platonov Ellrion

View GitHub Profile
@Ellrion
Ellrion / jquery.simpleplugin.js
Last active February 29, 2020 15:42
Jquery plugin template
/**
* JQuery plugin SimplePlugin v 1.0 [26.05.14 10:59]
* TODO: DESCRIPTION
* Created by ...
* Contacts: ...
*/
// don't declare anything out here in the global namespace
(function($) { // create private scope (inside you can use $ instead of jQuery)
@Ellrion
Ellrion / php-restrictions.nginxconf
Last active March 20, 2024 01:26
Nginx + Php-fpm config for Laravel app
# /etc/nginx/global/php-restrictions.conf
# Don't throw any errors for missing favicons and don't display them in the logs
location = /favicon.ico {
log_not_found off;
access_log off;
}
# Don't log missing robots or show them in the nginx logs
location = /robots.txt {
allow all;
@Ellrion
Ellrion / helper.php
Last active October 18, 2017 14:27
array_diff_assoc_recursive helper
<?php
function array_diff_assoc_recursive($aArray1, $aArray2) {
$aReturn = array();
foreach ($aArray1 as $mKey => $mValue) {
if (! array_key_exists($mKey, $aArray2)) {
$aReturn[$mKey] = $mValue;
continue;
}
@Ellrion
Ellrion / filters.php
Last active August 29, 2015 14:03
Route simple cache
<?php
//...
Route::filter('http_cache', function($route, $request, $value = 30, $response = null)
{
if ($value instanceof \Illuminate\Http\Response) {
list($response, $value) = [$value, $response];
}
$key = 'route-'.md5(Auth::id().Request::fullUrl().Request::method());
$route->after('http_cache:'.$value);
if ( is_null($response) && Cache::has($key) ) {
@Ellrion
Ellrion / SecurityFacade.php
Last active August 29, 2015 14:04
SimpleSecurity integration with Laravel (https://github.com/Ellrion/SimpleSecurity)
<?php
use Illuminate\Support\Facades\Facade;
/**
* @see \Ellrion\SimpleSecurity\Security
*/
class SecurityFacade extends Facade {
/**
@Ellrion
Ellrion / ActivityStatusScope.php
Created September 22, 2014 10:37
Laravel 4 Model GlobalScope
<?php
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\ScopeInterface;
class ActivityStatusScope
implements ScopeInterface
{
const STATUS_FIELD = 'status';
const ACTIVE = 1;
@Ellrion
Ellrion / ModelWithScope.php
Last active August 29, 2015 14:06 — forked from vanchelo/Post.php
Laravel 4 Global Scope (fields for select)
<?php
use Illuminate\Database\Eloquent\Model;
class ModelWithScope extends Model
{
use SelectableTrait;
protected $selectable = [
'id', 'title', 'created_at'
@Ellrion
Ellrion / LanguageDetector.php
Last active November 10, 2017 15:33
laravel localosation old (<=5.0)
<?php
class LanguageDetector
{
private $languages = [];
public function __construct($enabledLanguages)
{
$this->languages = (array)$enabledLanguages;
}
@Ellrion
Ellrion / cmd_cheat_sheet.md
Last active April 21, 2021 02:26
CMD cheat sheet

Файловые команды

  • ls – список файлов и каталогов
  • ls -al – форматированный список со скрытыми каталогами и файлами
  • cd dir – сменить директорию на dir
  • cd – сменить на домашний каталог
  • pwd – показать текущий каталог
  • mkdir dir – создать каталог dir
  • rm file – удалить file
  • rm -r dir – удалить каталог dir
  • rm -f file – удалить форсированно file