Skip to content

Instantly share code, notes, and snippets.

View kholschevnikov's full-sized avatar

Roman Kholschevnikov kholschevnikov

  • CityAds Media
  • Russia, Moscow
View GitHub Profile
@kholschevnikov
kholschevnikov / dos2unix.sh
Created April 23, 2018 10:28 — forked from jappy/dos2unix.sh
Shell script to convert files with CRLF to LF (Mac/Linux)
#! /bin/sh
for x
do
echo "Converting $x"
tr -d '\015' < "$x" > "tmp.$x"
mv "tmp.$x" "$x"
done
@kholschevnikov
kholschevnikov / roman.zsh-theme
Created April 13, 2018 08:11
Oh my zsh theme for Mac OS
PROMPT='[%{$fg[green]%}%m%{$reset_color%} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)%{$reset_color%}]$ '
ZSH_THEME_GIT_PROMPT_PREFIX="(%{$fg_bold[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX=")"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%} %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$reset_color%}"
@kholschevnikov
kholschevnikov / README.md
Last active March 7, 2018 14:38 — forked from brandt/README.md
Creates a loopback alias with IP 127.0.0.2 at startup on Mac OS X

Loopback Alias

Creates an alias on the loopback interface (lo0) with the IP 10.10.10.1 on macOS.

Installation

  1. Install the plist to: /Library/LaunchDaemons/com.runlevel1.lo0.10.10.10.1.plist
  2. Set mode: sudo chmod 0644 /Library/LaunchDaemons/com.runlevel1.lo0.10.10.10.1.plist
  3. Set owner: sudo chown root:wheel /Library/LaunchDaemons/com.runlevel1.lo0.10.10.10.1.plist
  4. Load: sudo launchctl load /Library/LaunchDaemons/com.runlevel1.lo0.10.10.10.1.plist
@kholschevnikov
kholschevnikov / phpx
Last active September 11, 2015 06:37
Alias php bin for use xdebug in cli
XDEBUG_CONFIG="idekey=PHPSTORM" PHP_IDE_CONFIG="serverName={имя сервера}" php -d "xdebug.remote_host={IP рабочей машины}" -d "xdebug.remote_connect_back=0" -d "xdebug.remote_port=9000" -d "xdebug.remote_enable=1" $@
@kholschevnikov
kholschevnikov / xdebug.ini
Last active April 13, 2018 07:58
xDebug for PHPStorm
[XDebug]
xdebug.remote_enable=true
xdebug.remote_connect_back=true
xdebug.remote_autostart=true
xdebug.profiler_enable=false
xdebug.max_nesting_level=700
xdebug.idekey=PHPSTORM
xdebug.remote_host=docker.for.mac.localhost
xdebug.remote_port=9002
@kholschevnikov
kholschevnikov / drop_all_tables_except_one.sql
Last active September 11, 2015 06:40
MySQL: Drop all table except one
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables FROM information_schema.tables
WHERE TABLE_SCHEMA = 'table_schema' AND TABLE_NAME <> 'table_name';
SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt1 FROM @tables;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
#!/bin/sh
date=$1
DRY_RUN=1
if [ -z $1 ]; then
echo "Empty date"
exit;
fi
@kholschevnikov
kholschevnikov / edit_comment_for_pushed_commit.sh
Last active September 11, 2015 06:54
Edit commit for pushed commit (and push to remote if needed)
git rebase --interactive c4d25d6^
# не меняем ничего кроме первого слова pick -> reword
reword c4d25d6 order status
pick 39ba64e redirect to order status after booking
# в следующем окне можно будет изменить комментарий
# если коммит был запушен
git push --force
@kholschevnikov
kholschevnikov / recover_lost_stash.sh
Last active September 11, 2015 06:55
Recovering a lost stash
Like a commit, a dropped or cleared stash is stored in a Git database until you run git gc. The lost stash is treated like a commit and you can use git fsck to find it.
Let's create and drop a stash with a message.
% echo "I'm going to stash this" >> INSTALL
% git add INSTALL
% git stash save Changes INSTALL
% git stash list
stash@{0}: On master: Changed INSTALL
% git stash clear
@kholschevnikov
kholschevnikov / get_tables_size.sql
Last active September 11, 2015 06:47
Размеры таблиц в Mysql
SELECT
concat(table_schema,'.',table_name) tableName,
concat(round(table_rows/1000000,2),'M') rows,
concat(round(data_length/(1024*1024),2),'M') DATA,
concat(round(index_length/(1024*1024),2),'M') idx,
concat(round((data_length+index_length)/(1024*1024),2),'M') totalSize,
round(index_length/data_length,2) idxFrac
FROM information_schema.TABLES
ORDER BY data_length+index_length DESC
LIMIT 10