Skip to content

Instantly share code, notes, and snippets.

View Ellrion's full-sized avatar

Maksim (Ellrion) Platonov Ellrion

View GitHub Profile
@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'
<?php
/**
* Naive Bayes classifier
*/
include __DIR__ . '/../vendor/autoload.php';
function train($samples)
{
@Ellrion
Ellrion / HigherOrderOptionalProxy.php
Created August 26, 2017 08:02 — forked from derekmd/Optional.php
Laravel global helper function `optional()`
<?php
namespace App\Support;
class HigherOrderOptionalProxy
{
/**
* The target being transformed.
* Use _ prefix to avoid namespace conflict on __get()
*
@Ellrion
Ellrion / .bash_aliases
Created May 7, 2018 12:23 — forked from vratiu/.bash_aliases
Git shell coloring
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset
@Ellrion
Ellrion / postgres_queries_and_commands.sql
Created May 25, 2018 14:12 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'