Skip to content

Instantly share code, notes, and snippets.

@wojteklu
wojteklu / clean_code.md
Last active May 8, 2024 09:12
Summary of 'Clean code' by Robert C. Martin

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

Alpine.directive('typed', (el, { expression, modifiers }, { evaluateLater, effect, cleanup }) => {
const getStrings = evaluateLater(expression);
const modifierValue = (key, fallback) => {
if (-1 === modifiers.indexOf(key)) {
return fallback;
}
const value = modifiers[modifiers.indexOf(key) + 1];
@hakerdefo
hakerdefo / sources.list
Created June 11, 2023 18:47
Debian 12 "bookworm" complete sources.list
deb https://ftp.debian.org/debian/ bookworm contrib main non-free non-free-firmware
# deb-src https://ftp.debian.org/debian/ bookworm contrib main non-free non-free-firmware
deb https://ftp.debian.org/debian/ bookworm-updates contrib main non-free non-free-firmware
# deb-src https://ftp.debian.org/debian/ bookworm-updates contrib main non-free non-free-firmware
deb https://ftp.debian.org/debian/ bookworm-proposed-updates contrib main non-free non-free-firmware
# deb-src https://ftp.debian.org/debian/ bookworm-proposed-updates contrib main non-free non-free-firmware
deb https://ftp.debian.org/debian/ bookworm-backports contrib main non-free non-free-firmware
@zhangyoufu
zhangyoufu / 99-replica-set.sh
Created June 10, 2019 11:07
ugly hack to initialize replica set for MongoDB docker container, put under /docker-entrypoint-initdb.d/
#!/bin/bash
: "${FORKED:=}"
if [ -z "${FORKED}" ]; then
echo >&2 'mongod for initdb is going to shutdown'
mongod --pidfilepath /tmp/docker-entrypoint-temp-mongod.pid --shutdown
echo >&2 'replica set will be initialized later'
FORKED=1 "${BASH_SOURCE[0]}" &
unset FORKED
mongodHackedArgs=(:) # bypass mongod --shutdown in docker-entrypoint.sh
@ttycelery
ttycelery / jingle-family-mart.txt
Last active May 8, 2024 09:05
Lirik Jingle Family Mart Lengkap 100%
// Transcribed manually from
// https://www.youtube.com/watch?v=GpUhmUVvD9Y
// Enjoy ;)
Hai kawan-kawan
Mari bekerja membangun bersama FamilyMart
Suka dan duka ada di FamilyMart
Semua keluarga kita
Mari menyapa pelanggan kita
@raulmoyareyes
raulmoyareyes / networkCommand.md
Last active May 8, 2024 09:03
Linux command to check Internet connection speed.

# View public IP

  • curl -s checkip.dyndns.org | sed 's#.Address: (.)</b.*#\1#'
  • wget -qO - icanhazip.com
  • curl ifconfig.me
  • curl ident.me
  • dig +short myip.opendns.com @resolver1.opendns.com
  • lynx -dump ifconfig.me | grep 'IP Address'
  • curl ipecho.net/plain
  • curl bot.whatismyipaddress.com
  • curl ipinfo.io
@codequokka
codequokka / start-tmux-automatically-on-zsh.zsh
Last active May 8, 2024 09:00
Start tmux automatically on zsh
# Start the tmux session if not alraedy in the tmux session
if [[ ! -n $TMUX ]]; then
# Get the session IDs
session_ids="$(tmux list-sessions)"
# Create new session if no sessions exist
if [[ -z "$session_ids" ]]; then
tmux new-session
fi
git_current_branch () {
local ref
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]
then
[[ $ret == 128 ]] && return
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
@msauza
msauza / spring-boot-docker.md
Last active May 8, 2024 08:59
Multi-Layer, Multi-Stage: Spring Boot application with Docker.

Overview

Spring Boot applications can run within a container by Multi-Layer based approach. Each layer may contain different parts of the application such as dependencies, source code, resources and even snapshot dependencies.

In the other hand, with Multi-Stage Build approach, any application can be built at a separate image from the final image that will contain the runnable application.

Spring Boot Docker

Multi-Layer

The citations game: Wolverton Ratios

Rubric: Software Engineering : Factual Claims : Defect Cost Increase : Wolverton Ratios

Context

See previous note on the IBM Systems Sciences Institute

In absolute numbers, the Wolverton are as follows: 139:455:977:7136:14102, claimed dollar costs of fixing an "average" defect. (Itself an absurd claim, see Leprechauns, I should perhaps write more on that.)