Skip to content

Instantly share code, notes, and snippets.

View kas-cor's full-sized avatar
🏠
Working from home

Alexsander kas-cor

🏠
Working from home
  • kas-cor
  • World
View GitHub Profile
@kas-cor
kas-cor / self_deploy.sh
Created May 10, 2023 15:23
Self PHP Deploy
#!/bin/sh
# Developer deploy, if change in dev branch then run deploy_dev.sh
cd /path/to/site && git fetch
if [[ $(git log --oneline -n1 dev..origin/dev) ]]; then
echo Delpoy dev...
./deploy_dev.sh
fi
# Prodaction deploy, if change in master branch then run deploy_prod.sh
@kas-cor
kas-cor / xfreerdp.sh
Last active October 11, 2022 20:27
xfreerdp
#!/bin/bash
xfreerdp /u:user /p:password /f /v:server:port +clipboard
@kas-cor
kas-cor / install_docker.sh
Last active July 26, 2022 07:53
Install docker
#!/bin/bash
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
newgrp docker
@kas-cor
kas-cor / install_mailhog.sh
Last active February 5, 2022 18:19
Install MailHog in Manjaro Linux
#!/bin/bash
# Install Go
sudo pacman -S --noconfirm go
# Build MailHog and mhsendmail from source in GitHub
go get github.com/mailhog/MailHog
go get github.com/mailhog/mhsendmail
# Copy execucate files
@kas-cor
kas-cor / docker-compose.yml
Last active September 4, 2022 15:49
shadowsocks
version: '2'
services:
shadowsocks:
image: shadowsocks/shadowsocks-libev:latest
environment:
- TZ=Europe/Moscow
- PASSWORD=<password>
- METHOD=chacha20-ietf-poly1305
- DNS_ADDRS=1.1.1.1,1.0.0.1
- ARGS=--fast-open --no-delay --reuse-port
@kas-cor
kas-cor / get_number_by_string.php
Last active July 9, 2022 17:41
Получить число из строки
<?php
/**
* Получить число из строки
* @param string $string Исходная строка
* @param int $min Минимальная граница (0 по умолчанию)
* @param int $max Максимальная граница (100 по умолчанию)
* @param int $precision Точность от 1 до 32 (16 по умолчанию)
* @return int
*/
@kas-cor
kas-cor / script_cookies_agree.js
Last active April 21, 2021 12:11
Cookies agree for sites | Плашка для принятия обработки кукисов.
$(function () {
if (!$.cookie('cookies_agree')) {
$("body").append([
'<div class="cookies_agree">',
'<div style="width: 80%; text-align: center; padding: 10px;">',
'Продолжая работу с ' + location.hostname + ', Вы подтверждаете использование сайтом cookies Вашего ',
'браузера с целью улучшить предложения и сервис на основе Ваших предпочтений и интересов.',
'</div>',
'<div style="width: 20%; text-align: center; padding: 10px;">',
'<button type="button" style="padding: 5px;">Понятно</button>',
@kas-cor
kas-cor / remove_all_branches_except_master.sh
Last active August 5, 2021 17:32
Git remove all branches except master
# Удалить все ветки кроме master
git checkout master && git branch | grep -v "* master" | xargs git branch -D
@kas-cor
kas-cor / optimize_repositories.sh
Last active January 29, 2021 22:54
Finding and optimize repositories in current directory
current_dir=$PWD
echo "Finding repositories in $current_dir" && echo
for repo in `find ${current_dir} | grep ".git$"`
do
echo "Repository ${repo%.git} size `du -hcs ${repo} | grep 'total\|итого'`"
cd ${repo%.git} && git gc > /dev/null 2>&1
echo "Size after optimization `du -hcs ${repo} | grep 'total\|итого'`" && echo
cd ${current_dir}
done
@kas-cor
kas-cor / strong.sh
Created September 23, 2019 16:15
ssh-keygen
# gen ed25519
ssh-keygen -o -a 100 -t ed25519
# gen strong rsa
ssh-keygen -t rsa -b 4096 -o -a 100
# new passphrase
ssh-keygen -f ~/.ssh/id_rsa -p -o -a 100
# ssh-agent