Skip to content

Instantly share code, notes, and snippets.

@wojteklu
wojteklu / clean_code.md
Last active September 29, 2023 15:29
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

@Kartones
Kartones / postgres-cheatsheet.md
Last active September 29, 2023 12:40
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)
@zmts
zmts / tokens.md
Last active September 29, 2023 12:10
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication
View tokens.md
@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
@ssrihari
ssrihari / clojure-learning-list.md
Last active September 26, 2023 22:55
An opinionated list of excellent Clojure learning materials
View clojure-learning-list.md
@dhh
dhh / documents.rb
Last active September 24, 2023 19:05
View documents.rb
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@mihow
mihow / load_dotenv.sh
Last active September 23, 2023 14:55
Load environment variables from dotenv / .env file in Bash
View load_dotenv.sh
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
View libuv-vs-libev.md

Libuv and libev, two I/O libraries with similar names, recently had the privilege to use both libraries to write something. Now let's talk about my own subjective expression of common and different points.

The topic of high-performance network programming has been discussed. Asynchronous, asynchronous, or asynchronous. Whether it is epoll or kqueue, it is always indispensable to the asynchronous topic.

Libuv is asynchronous, and libev is synchronous multiplexing IO multiplexing.

Libev is a simple encapsulation of system I/O reuse. Basically, it solves the problem of different APIs between epoll and kqueuq. Ensure that programs written using livev's API can run on most *nix platforms. However, the disadvantages of libev are also obvious. Because it basically just encapsulates the Event Library, it is inconvenient to use. For example, accept(3) requires manual setnonblocking after connection. EAGAIN, EWOULDBLOCK, and EINTER need to be detected when reading from a socket. This is a

@Kukunin
Kukunin / ractors.rb
Last active September 22, 2023 09:46
Ruby Ractors vs Threads benchmark
View ractors.rb
require 'benchmark'
require 'etc'
Ractor.new { :warmup } if defined?(Ractor)
def fibonacci(n)
return n if (0..1).include? n
fibonacci(n - 1) + fibonacci(n - 2)
end