Skip to content

Instantly share code, notes, and snippets.

View Vladnev's full-sized avatar

Vladyslav Nevhen Vladnev

View GitHub Profile
@Vladnev
Vladnev / toogle_display
Created August 22, 2019 11:05
Comand for toogle dispaly
Before use replace <DisplayOffPort> && <ActiveDisplayPort>
Values you can get by `xrandr | grep " connected " | awk '{ print$1 }'`
xrandr --listactivemonitors | grep <DisplayOffPort> >/dev/null && xrandr --output <DisplayOffPort> --off || xrandr --output eDP1 --below <ActiveDisplayPort> --auto
@Vladnev
Vladnev / .gitconfig
Last active October 6, 2023 09:30
Git configuration file
[user]
name = <NAME>
email = <EMAIL>
[alias]
go = checkout
co = "commit -m"
co-name = "!git add --all | git commit -m \"$(git branch-name)\""
do = checkout -b
to = push origin
amend = commit --amend --no-edit
@Vladnev
Vladnev / grep.txt
Created December 26, 2017 15:04
Grep usage
grep <pattern> <file>
grep -Hsi <pattern> <dir>
flags:
-r - recursive(include subdirs)
-l - show only filenames where was found pattern
-H - show in which file was found row
-с - count of pattern matches
-v - show only non-matches
-i - ignore case
@Vladnev
Vladnev / sql_start.txt
Created November 28, 2017 15:18
First start of mysql server
sudo mysql -u root
DROP USER 'root'@'localhost';
CREATE USER 'root'@'localhost' IDENTIFIED BY ''; - for all hosts change localhost to %, not recommend
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost';
FLUSH PRIVILEGES;
exit
@Vladnev
Vladnev / git commands
Last active August 1, 2018 11:49
Count code rows by author
Count commits by author:
git log --pretty=format:==%an --numstat | \
sed -r '/==.*/{s/^==//;h;D};/^$/D;s/-/0/g;s/\t[^\t]+$//;G;s/(.*)\n(.*)/\2\t\1/' \
| awk -F '\t' '{add[$1]+=$2;del[$1]+=$3} END {for (i in add) {print i,add[i],del[i]}}'
Delete branches(not current && not master):
alias clear-merged-branches='git branch --merged | grep -v -E "(^\*|\bmaster\b)" | xargs git branch -d'
alias clear-branches='git branch | grep -v -E "(^\*|\bmaster\b)" |xargs git branch -D'
@Vladnev
Vladnev / parse_git_branches.sh
Last active November 20, 2017 10:32
Bash function for show git branches in subdirs
function show_branches()
{
for sub in *; do
[[ -d "${sub}/.git" ]] || continue
local BRANCH="$(cd "$sub"; git for-each-ref refs/heads/$(git branch 2>/dev/null|sed -n '/^\*/s/^\* //p') --format='%(authordate:short)%09(%(committerdate:relative))%09[%1B[0;33m%(refname:short)%1B[m]')"
echo "$sub $BRANCH"
done
}
@Vladnev
Vladnev / random.sql
Created October 27, 2017 14:37
Random row sql
SELECT r1.id
FROM forms AS r1 JOIN
(SELECT (RAND() *
(SELECT MAX(id)
FROM forms)) AS id)
AS r2
WHERE r1.id >= r2.id
ORDER BY r1.id ASC
LIMIT 1;
SELECT f.id + 1 AS empty
FROM <table> f
LEFT OUTER JOIN <table> r ON f.id + 1 = r.id
WHERE r.id IS NULL
ORDER BY f.id
LIMIT 1;
SELECT f.id + 1 AS empty
FROM <table> f
PPA:
sudo add-apt-repository ppa:ondrej/php-zts || sudo add-apt-repository ppa:nhojohl/php7-zts
sudo apt-get update
sudo apt-get install php7.0-zts php7.0-zts-dev
PHTHREADS:
cd ~/
git clone git://github.com/krakjoe/pthreads.git
cd pthreads
@Vladnev
Vladnev / .gitignore
Created April 5, 2017 06:35
Git ignore file
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #