Skip to content

Instantly share code, notes, and snippets.

Николай Шангин shanginn

Block or report user

Report or block shanginn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
shanginn / task.awk
Created Feb 18, 2018
Yandex SHKIB task 5. # Usage: ./task.awk shkib.csv > result.txt
View task.awk
#!/usr/bin/gawk -f
FS = ","
PROCINFO["sorted_in"] = "@val_num_desc"
if ($2 != "") {
# Sublime Text 3 install with Package Control (last update: 25 September 2016)
# No need to download this script, just run it on your terminal:
# $ curl -L | sh
# Detect the architecture
shanginn /
Last active Mar 5, 2017
Get available relationships trait for Eloquent model (Laravel 5.*)

GetRelationships Trait

This trait will allow you to get defined relationships on the model. I wish Laravel have a way to get this without any additions(except for trait), but there is no way.

Here we have 2 versions of the trait: for PHP7 and for PHP5.

Both method uses Reflections to collect information about the model.


With PHP7 version you'll only need to add return class for the relationship method like this:

shanginn / BootstrapLastTab.js
Created Jan 13, 2016
Make Bootstrap 3 remember which tab they were on. Works only with one set of tabs.
View BootstrapLastTab.js
var $tabLinks = $('a[data-toggle="tab"]');
if($tabLinks.length) {
var lastTab = localStorage.getItem('lastTab');
$tabLinks.on('click', function (e) {
//save the latest tab; use cookies if you like 'em better:
localStorage.setItem('lastTab', $('href'));
//go to the latest tab, if it exists:
var $target = lastTab ? $('a[href="' + lastTab + '"]') : $tabLinks.first();
You can’t perform that action at this time.