Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
echo -en "\033[31mYou're about to push master, is that what you intended? [y|n] \033[0m"
echo -en "\033[1m"
read -n 1 -r < /dev/tty
@Bogdaan
Bogdaan / git-preventpush-pre-hook.sh
Created September 13, 2022 09:06
git: prompt on push to protected branch
#!/bin/bash
# Warn before pushing to protected branches
# Make script executable with chmod +x pre-push
# Bypass with git push --no-verify
BRANCH=`git rev-parse --abbrev-ref HEAD`
PROTECTED_BRANCHES="^(master|main)"
if [[ "$BRANCH" =~ $PROTECTED_BRANCHES ]]; then
read -p "Are you sure you want to push to \"$BRANCH\" ? (y/n): " -n 1 -r < /dev/tty
@Bogdaan
Bogdaan / install-php_7.4.0.sh
Created December 13, 2021 13:30 — forked from abenevaut/# install php 7.4.0.md
Install phpbrew && php 7.4.0 on macOS
xcode-select --install
# You should install brew https://brew.sh/index_fr
brew install automake autoconf curl pcre bison re2c mhash libtool icu4c gettext jpeg openssl libxml2 mcrypt gd gmp libevent zlib libzip bzip2 imagemagick pkg-config oniguruma
brew link --force icu4c
brew link --force openssl
brew link --force libxml2
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
chmod +x phpbrew
security add-generic-password -a login -s service -w password
@Bogdaan
Bogdaan / json-to-csv.sh
Created April 28, 2021 16:05
json-to-csv.sh
cat input.json | jq -c '.results[] | {name, party, cash: .cash_on_hand} | select(.cash | tonumber > 1000000)'
@Bogdaan
Bogdaan / remove-merged.sh
Created October 8, 2020 07:13
Remove merged git branches
git branch --merged| egrep -v "(^\*|master|dev|stage)" | xargs git branch -d
@Bogdaan
Bogdaan / mysq-general-log.sql
Created July 6, 2020 18:52
Mysql query log to table
CREATE TABLE `slow_log` (
`start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`query_time` time NOT NULL,
`lock_time` time NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
set foreign_key_checks = 0;
drop table men;
drop table hobbies;
drop table man_hobbies;
set foreign_key_checks = 1;
create table if not exists men
(
id bigint unsigned auto_increment not null,
name varchar(255) not null,
@Bogdaan
Bogdaan / grc.conf.gotest
Created June 21, 2020 16:38
grc config for go
regexp==== RUN .*
colour=blue
-
regexp=--- PASS: .*
colour=green
-
regexp=^PASS$
colour=green
-
regexp=^(ok|\?) .*
@Bogdaan
Bogdaan / size.sql
Created June 12, 2020 17:57
table size in gb
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;