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
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
BEGIN {
FS = ","
PROCINFO["sorted_in"] = "@val_num_desc"
}
{
if ($2 != "") {
most_requests[$2]++
View install_sublime_text.sh
#!/bin/sh
# 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 git.io/sublimetext | sh
# Detect the architecture
@shanginn
shanginn / README.md
Last active Mar 5, 2017
Get available relationships trait for Eloquent model (Laravel 5.*)
View README.md

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.

PHP7

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

@shanginn
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', $(e.target).attr('href'));
});
//go to the latest tab, if it exists:
var $target = lastTab ? $('a[href="' + lastTab + '"]') : $tabLinks.first();
$target.tab('show');
You can’t perform that action at this time.