Skip to content

Instantly share code, notes, and snippets.

@salarmehr
salarmehr / .bashrc
Created July 24, 2021 18:42
.bashrc
# Directories
alias ll='ls -FGlAhp'
alias lz='ls --human-readable --size -1 -S --classify' #Sort by file size
alias left='ls -t -1' #Sort by modification time
alias ..="cd ../"
alias ...="cd ../../"
alias ....="cd ../../../"
alias .....="cd ../../../../"
@salarmehr
salarmehr / .gitconfig
Last active July 25, 2021 17:25
Git aliases that you cannot live without them
[core]
autocrlf = false
[push]
default = current
# push tags missing from remote
# See https://git-scm.com/docs/git-push#git-push---follow-tags
followTags = true
[pull]
default = current
[rebase]
@salarmehr
salarmehr / ajax_exception.md
Last active February 12, 2020 05:45
Force Laravel to send regular exception on Ajax call instead of JSON excption

vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:187

        return $request->expectsJson()
                    ? $this->prepareJsonResponse($request, $e)
                    : $this->prepareResponse($request, $e);

replace or extend the function with

Use "CamelHumps" words -> checked
Change font size (Zoom) with Ctrl+ Mouse Wheel -> checked
// run in in console or create a brower bookmark prefixing it with `javascript:` and copy this gist as url.
// now you can click on the bookmakr button ot copy the git command to clipboard.
function copy(text) {
var input = document.createElement('input');
input.setAttribute('value', text);
document.body.appendChild(input);
input.select();
var result = document.execCommand('copy');
document.body.removeChild(input);
@salarmehr
salarmehr / handy_git_commands.sh
Last active February 10, 2020 02:52
Git commands
git branch --merged | egrep -v "(^\*|master|develop)" | xargs git branch -d
git reset HEAD^ # remove commit locally
git push origin +HEAD # force-push the new HEAD commits
#Delete a remote GIT branch
# To delete a remote branch you can use the following command:
git push {remote_name} --delete {branch_name}
@salarmehr
salarmehr / php_arrays.txt
Last active January 18, 2020 23:21
PHP array functions grouped
K works on keys
V working on Values
E returns values indicates an exception
C can work on both key or valeus depencs on params
P preserve the keys from input arrays
R get array by refrence
Array creation
==============
@salarmehr
salarmehr / art_of_naming.md
Last active January 17, 2020 00:22
Art of identifier namining

Dynamic identifiers (functions and methods)

Functions are verbs. If they do some actions on the system, we use imperative verb. A single verb is preferred when possible. e.g.

$user->activate();
$order->confirm();

if the functions are handling and event just prefix the event name with on.

// while Jira has a create branch botton, it take some seconds to create a branch and use it locally
// it's quicker to generate the git command and run it locally.
// run in in console or create a brower bookmark prefixing it with `javascript:` and copy this gist as url.
// now you can click on the bookmakr button ot copy the git command to clipboard.
function copy(text) {
var input = document.createElement('input');
input.setAttribute('value', text);
document.body.appendChild(input);
input.select();
@salarmehr
salarmehr / gist:07ce72c11feddade7e02367a605b6b33
Created September 23, 2017 08:52
Making vendor folder smaller for product deployment.
gulp.task('zip-vendor', function () {
return gulp.src(
[
'vendor/**/*',
'!vendor/kartik-v/**',
'!vendor/**/*.md',
'!vendor/**/*.txt',
'!vendor/**/*.pdf',
'!vendor/**/LICENSE',
'!vendor/**/CHANGES',