Skip to content

Instantly share code, notes, and snippets.

View harini-ua's full-sized avatar
🏠
Working from home

Sergey Harini harini-ua

🏠
Working from home
View GitHub Profile
@harini-ua
harini-ua / git-aliases.sh
Last active August 25, 2022 17:34
Git Aliases
# To show users from all branches (not only the ones in the current branch) you have to add --all flag
# git authors --all
# This is also great for checking who touched a specific file rather than the whole project. You must add the path to the file at the end.
# git authors <path_to_file>
git config --global alias.authors 'shortlog --summary --numbered --email'
# Rename the branch
# git rename <current_branch_name> <new_branch_name>
git config --global alias.rename 'branch -m'
@harini-ua
harini-ua / git-reset-author.sh
Created August 25, 2022 17:14
Git reset author for all commits
#!/bin/sh
git filter-branch -f --env-filter "
GIT_AUTHOR_NAME='Newname'
GIT_AUTHOR_EMAIL='new@email'
GIT_COMMITTER_NAME='Newname'
GIT_COMMITTER_EMAIL='new@email'
" HEAD
@harini-ua
harini-ua / ua.php
Last active September 21, 2020 10:37
<?php
return [
'alphabet' => [
// https://www.kmu.gov.ua/npas/243262567
'gov' => [
'а' => 'a',
'б' => 'b',
'в' => 'v',
'г' => 'h',
@harini-ua
harini-ua / all.sh
Created September 19, 2019 10:39 — forked from lukrizal/all.sh
#!/bin/bash
echo "Downloading GetDeb and PlayDeb" &&
wget http://archive.getdeb.net/install_deb/getdeb-repository_0.1-1~getdeb1_all.deb http://archive.getdeb.net/install_deb/playdeb_0.3-1~getdeb1_all.deb
echo "Installing GetDeb" &&
sudo dpkg -i getdeb-repository_0.1-1~getdeb1_all.deb
echo "Installing PlayDeb" &&
sudo dpkg -i playdeb_0.3-1~getdeb1_all.deb &&
@harini-ua
harini-ua / Controller.php
Created October 17, 2018 12:57
Get validation error messages in Lumen & Dingo API project
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Dingo\Api\Exception\ValidationHttpException;
use Laravel\Lumen\Routing\Controller as BaseController;
class Controller extends BaseController
{
@harini-ua
harini-ua / Handler.php
Last active October 26, 2018 10:26
Handle REST API errors thrown from Controller or Exception
<?php
namespace Attend\Exceptions;
use Exception;
use Attend\Traits\RestTrait;
use Attend\Traits\RestExceptionHandlerTrait;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
@harini-ua
harini-ua / Distance.php
Last active July 12, 2020 13:45
Calculated distance between two GPS locations. Using the Haversin formula. [MySQL, PHP, JAVA, JavaScript, Python, Node.js]
<?php
namespace HaversineFormula;
const EARTH_RADIUS = 6371;
const KILOMETER_TO_MILE = 0.621371192;
class Distance
{
/**
@harini-ua
harini-ua / CheckForMaintenanceMode.php
Created August 10, 2017 12:22
Custom middleware Laravel 5 check for maintenance mode.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Routing\Route;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Original;
@harini-ua
harini-ua / first-element-array.php
Last active October 17, 2018 12:57
Get the first element of an array php.
<?php
$array = [
4 => 'Wednesday',
6 => 'Friday',
1 => 'Sunday',
5 => 'Thursday',
3 => 'Tuesday',
7 => 'Saturday',
2 => 'Monday'
<?php
namespace App\Services;
use App\Post;
use Carbon\Carbon;
use Illuminate\Support\Facades\Cache;
class SiteMap
{
/**
* Return the content of the Site Map
*/