Skip to content

Instantly share code, notes, and snippets.

View ivanbogomoloff's full-sized avatar

ivan ivanbogomoloff

View GitHub Profile
@ivanbogomoloff
ivanbogomoloff / bashrc
Created February 19, 2019 09:13
Append to PS1 info about current version control system and branch name
# .bashrc
#
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
@ivanbogomoloff
ivanbogomoloff / commit-msg
Created February 19, 2019 09:11
Automatically adds branch name and branch description to every commit message.
#!/bin/sh
# Place it to .git/hooks/commit-msg and chmod +x .git/hooks/commit-msg
# Automatically adds branch name and branch description to every commit message.
#
NAME=$(git branch | grep '*' | sed 's/* //')
DESCRIPTION=$(git config branch."$NAME".description)
echo "$NAME"'/'$(cat "$1") > "$1"
if [ -n "$DESCRIPTION" ]
then
@ivanbogomoloff
ivanbogomoloff / gist:d659d8d286719a83c811a84aaa9194d0
Created October 25, 2018 09:46
i3wm selected interactive screenshot with scrot to clipboard
i3-msg exec "scrot -s selected_area_screen.png && cat selected_area_screen.png | xclip -selection clipboard -t image/png -i"
@ivanbogomoloff
ivanbogomoloff / gist:a4e9a092fc36befc6321bc8a65bf049c
Created October 23, 2018 20:56
git and hg branch in prompt PS1
# .bashrc
# ~/.bashrc file
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
export PS1=\[\033[1;37m\]\w(\D{%T})\[\033[33m\]$(gb)\[\033[00m\]$
@ivanbogomoloff
ivanbogomoloff / gist:50a0798e4a46f6d585b616c58879962a
Created February 14, 2018 04:21
i3lock 2 monitor tiled screen
bindsym $mod+Shift+h exec i3lock -i gitp.pb.pngng -t -p default -n
xrandr --output VGA1 --right-of HDMI1
@ivanbogomoloff
ivanbogomoloff / Free mem
Created February 13, 2018 10:21
i3wm free memory and status modify script
###File name is free_m
mem_free()
{
TYPE=free
awk -v type=$TYPE '
/^MemTotal:/ {
mem_total=$2
}
/^MemFree:/ {
@ivanbogomoloff
ivanbogomoloff / gist:5cf8b5ef42ab42a1ca164e3bc6fd0def
Last active January 16, 2018 13:49
Php sum from two string that over 65535 int
<?php
$str = '11000000000000000000000 33';
//echo 11000000000000000000000+33 will produce 1.1E+22983411000000000000000000030
//but with this code you will get 11000000000000000000033
$e = explode(" ", $str);
$num1 = $e[0];
$num2 = $e[1];
//100
// 10
@ivanbogomoloff
ivanbogomoloff / functions.php
Last active November 1, 2017 09:06
Wordpress override login, logout urls and remove wp login php
//Cop wp-login.php into any_login_admin_page.php
//then delete wp-login.php
//then write this...
add_filter('login_url', function($login_url, $redirect = '', $force_reauth = false) {
$login_url = site_url( '/any_login_admin_page.php', 'login' );
if ( ! empty( $redirect ) ) {
$login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url );
}
if ( $force_reauth ) {
$login_url = add_query_arg( 'reauth', '1', $login_url );