Skip to content

Instantly share code, notes, and snippets.

@mihow
mihow / load_dotenv.sh
Last active March 22, 2023 02:35
Load environment variables from dotenv / .env file in Bash
View load_dotenv.sh
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
View mysql-docker.sh
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@wojteklu
wojteklu / clean_code.md
Last active March 21, 2023 21:17
Summary of 'Clean code' by Robert C. Martin
View clean_code.md

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@iangreenleaf
iangreenleaf / gist:b206d09c587e8fc6399e
Last active March 21, 2023 19:53
Rails naming conventions
View gist:b206d09c587e8fc6399e

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

@mohanpedala
mohanpedala / bash_strict_mode.md
Last active March 21, 2023 07:09
set -e, -u, -o, -x pipefail explanation
@zmts
zmts / tokens.md
Last active March 21, 2023 03:09
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication
View tokens.md

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@Kartones
Kartones / postgres-cheatsheet.md
Last active March 20, 2023 21:41
PostgreSQL command line cheatsheet
View postgres-cheatsheet.md

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@kevinSuttle
kevinSuttle / meta-tags.md
Last active March 18, 2023 12:34 — forked from lancejpollard/meta-tags.md
List of Usable HTML Meta and Link Tags
@tadas-s
tadas-s / mysql-rename-db.sh
Created April 18, 2013 08:58
MySQL database rename script
View mysql-rename-db.sh
#!/bin/bash
# Disclaimer - make backups, use at your own risk.
#
# Based on this comment: http://stackoverflow.com/a/13944924/843067
# Views and stored procedures have to be done separately.
OLDDB="old_db_name"
NEWDB="new_db_name"
MYSQL="mysql -u root -pyour_password "
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active March 10, 2023 09:34
how to delete a git tag locally and remote
View git-tag-delete-local-and-remote.sh
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName