Înapoi la articole →

Cel mai recent articol

Ultima verificare

Urmăritori 0 urmăritori
Articole: 137
  1. Chroot in Linux with Encrypted Btrfs

    Prerequisites Link to heading Go into root mode: sudo -i Look for your drive: lsblk -f # NAME FSTYPE LABEL # nvme0n1 # ├─nvme0n1p1 vfat EFI # └─nvme0n1p2 crypto_LUKS You should have: nvme0n1p1 → EFI partition nvme0n1p2 → root LUKS Usa…

  2. Generate QR Code from CLI

    Prereqisites Link to heading sudo pacman -S qrencode Also make sure you have a proper UTF8 font installed!

  3. Terraform Format in CI

    Install git and make in your terraform docker image: # ------------------------------------------------------------------------------ # Packages RUN set -exo pipefail && \ \ echo 'Installing packages'

  4. Rails: install Administrate

    Gems Link to heading Add these to your Gemfile: # Administration gem 'administrate', '~> 0.20.0' # Authentication gem 'devise', '~> 4.9', '>= 4.9.3' Then install your new gems: bundle install Generate Link to heading bundle exec rails generate devise:i…

  5. Rails: install ActiveAdmin

    Gems Link to heading Add these to your Gemfile: # Administration gem 'activeadmin', '~> 4.0.0.beta4' # Authentication gem 'devise', '~> 4.9', '>= 4.9.3' Then install your new gems: bundle install Generate Link to heading bundle exec rails generate acti…

  6. Create new Rails app through Docker

    Prerequisites Link to heading Install Docker Here.

  7. Disallow GPT in robots.txt

    Enable robots.txt in your hugo.toml (formerly config.toml): enableRobotsTXT = true Add a file layouts/robots.txt with: User-agent: GPTBot Disallow: / User-agent: * Allow: /

  8. Create a new Ruby gem

    Setup Link to heading Add this to your ~/.bundle/config --- BUNDLE_GEM__TEST: "minitest" BUNDLE_GEM__CI: "gitlab" BUNDLE_GEM__MIT: "false" BUNDLE_GEM__COC: "false" BUNDLE_GEM__CHANGELOG: "false" BUNDLE_GEM__LINTER: "rubocop" Gem Name Link to heading Use…

  9. RSpec Instance Double

    Here is how you can make an assertion on a nested call to another class: let(:double) { instance_double('something') } before do allow(SomeClass).to receive(:some_method).and_return(double) allow(double).to receive(:another).and_return(true) end it…

  10. Easter Eggs: Pacman

    Open your pacman.cfg file: sudo vim /etc/pacman.conf Uncomment or add these instructions: Color ILoveCandy Update your system with sudo pacman -Syyu.

  11. How to Use: sha256sum

    Prerequisites Link to heading Create a basic file: echo "abc123" > test123.txt Digest Link to heading Find the sha256sum of a file with: sha256sum test123.txt You will get the following result: 5ecf8d2cc410094e8b82dd0bc178a57f3aa1e80916689beb00fe56148b1…

  12. Extract text from page using XPath

    let result = document.evaluate( '/html/body/div/main/div[1]/div[3]/div', document, null, XPathResult.STRING_TYPE, null )?.

  13. Ansible noop, resume, and skip

    Put one noop task at the beginning and end of your role: --- - name: ToolInstall ansible.builtin.meta: noop #

  14. Evil Mode: silence movement warnings

    If you’re tired of seeing these: evil-line-move: Beginning of buffer [81 times] evil-line-move: End of buffer [32 times] evil-forward-char: End of line [66 times] evil-backward-char: Beginning of line [66 times] Add these lines to your dotspacemacs/user-…

  15. Ruby Ractor: pass an arbitrary block

    Let’s say you have a piece of code: class SomeThing def initialize(thing) @thing = thing end def call puts @thing.inspect end end You want to execute this in parallel in a ractor: Ractor.new { SomeThing.new(1).call } This works if you h…

  16. Git init without branch hint

    If you run git init you will get this yellow hint: hint: Using 'master' as the name for the initial branch.

  17. Git root empty commit

    The best way to structure yout repository is to have an empty root commit and to squash all the other commits periodically onto the second.

  18. Linux Bootable USB

    Usage Link to heading sudo dd \ bs=4M status=progress oflag=direct conv=fsync \ if=/path/to/linux.iso \ of=/dev/sda Details Link to heading bs: Buffer size status=progress: shows 37497…

  19. Concatenate shell commands

    Steps Link to heading Fetch a command with either: C-e C-u: go to end of line, cut until beginning of line.

  20. Prepend to $PATH in bash

    You should always check if the value is present in a list before adding it in. function prepend_path () { case ":${PATH}:" in *:"$1":*) ;; *) PATH="$1:${PATH}" esac } Usage Link to heading prepend_path ~/.local/bin Cleanup Link to…

  21. Pretty print Linux $PATH

    Bash echo $PATH | sed "s/:/\n/g"

  22. Ruby Version Manager: rbenv

    Docker Link to heading The best way to manage ruby for your project is by using Docker: Docker Images: basic Ruby setup Docker Projects If you don’t have a Docker setup yet, you have to suffer, temporarily, by using rbenv.

  23. How to install Homebrew securely

    The instructions at https://brew.sh/ are extremely dangerous!

  24. Test for Emacs compiler warnings

    Setup Link to heading Your .gitignore: *.elc A Makefile containing: .PHONY: compile compile: @emacs -q -batch \ --eval '(setq byte-compile-error-on-warn t)' \ -f batch-byte-compile \ *.el The first indentation is a tab, the following two are s…

  25. Git refined diff output

    Package Link to heading Find the location of your diff-highlight package: Manjaro/Arch pacman -Ql git | grep diff-highlight Debian/Ubuntu dpkg -L git | grep diff-highlight Fedora rpm -ql git | grep diff-highlight Configure Link to heading Edit your ~/.…

  26. How to Use: ansible-lint

    Install Link to heading From package: # Manjaro / Arch sudo pacman -S ansible-lint # Alpine apk add --update ansible-lint From Docker (no official image so use mine): docker run --rm -it -v "$PWD":/work -w /work sdwolfz/ansible-lint:latest sh Configure…

  27. Disable annoying Linux bell sound

    Basic Link to heading sudo echo 'blacklist pcspkr' > /etc/modprobe.d/nobeep.conf And restart your machine!

  28. HTML Tabs without Javascript

    HTML Link to heading <div class="tabs tab-right"> <style> .tabs input#tab1:checked ~ .tab-content-1, .tabs input#tab2:checked ~ .tab-content-2, .tabs input#tab3:checked ~ .tab-content-3 { display: block; } </style> <input type…

  29. Check for Git differences in CI

    The command is: git diff --exit-code Prints the diff and exits with status code 1.

  30. Local packages in Spacemacs

    Are you a hardcore elisp programmer?

  31. How to Use: esbuild

    Install Link to heading npm init npm install --save-dev esbuild Setup Link to heading Add this to your esbuild.js file: const esbuild = require('esbuild') const targets = ['chrome58', 'firefox57', 'safari11'] esbuild.build({ entryPoints: ['src/main.j…

  32. Ruby Benchmarking

    Tips Link to heading Disable garbage collection when benchmarking for more accurate results.

  33. How to Use: Minitest Mocks

    Prerequisite Link to heading Ruby Minitest and Simplecov starter Usage Link to heading # Create a mock mock = Minitest::Mock.new # Add expectations. # # Arguments: # 1.

  34. Ruby HTTP calls

    Setup Link to heading Use the basic, standard, bundled, ruby HTTP library, no other gem needed. require 'net/http' url = 'https://www.codrut.pro' headers = { 'X-HELLO' => 'world' } use_ssl = true GET Link to heading params = { 'a' => 1 } result = nil

  35. Edit linux application shortcuts

    Locations: # System /usr/share/applications/ /usr/local/share/applications/ # Flatpak /var/lib/flatpak/exports/share/applications/ # Snap /var/lib/snapd/desktop/applications/ # Local ~/.local/share/applications/ Search for your application in those di…

  36. JournalCTL cheatsheet

    History Link to heading View history: journalctl -b Tail history: journalctl -b -f Cleanup Link to heading sudo journalctl --vacuum-size=100M

  37. Ruby: pass around a block

    You have the following: callable = proc { puts 'Hello' } Pass it to a function like this: def pass_me_something yield if block_given?

  38. Emacs Lisp macro to evaluate arguments

    One argument: (defmacro macro-evaluates-arg (arg) "Evaluate `ARG'."

  39. Git branch names

    Rules Link to heading Here are my rules for git branch names: Don’t start with the letter m, that’s reserved for master or main.

  40. Remove node package funding spam

    JavaScript developers have no dignity!

  41. Check if a port is open

    Install Link to heading sudo pacman -S openbsd-netcat Use Link to heading With an IP: nc -v 127.0.0.1 5432 Or a URL: nc -v www.codrut.pro 443

  42. List all open ports

    netstat -atun Now either grep or browse to see if you accidentally exposed your database to the world.

  43. Shell script infinite loop

    Useful for all sorts of things: while true; do echo 'Inside the loop'; sleep 5; done

  44. Webpack and Babel setup for Javascript

    Setup package.json by running: npm init -y Add packages: npm install --save-dev \ @babel/core \ @babel/preset-env \ babel-loader \ webpack \ webpack-cli Create webpack.config.js with index.js as your main, and…

  45. Ruby CSV manipulation

    Read Link to heading file = CSV.open('path/to/file.csv', col_sep: ',') file.each do |line| pp line end Write Link to heading header = ['A', 'B', 'C'] content = [[1, 2, 3], [4, 5, 6]] csv = CSV.generate do |output| output << header content.each do

  46. Remove metadata from images and documents

    Every image or document you create has built in spyware, remove it like this: Install Link to heading sudo pacman -S perl-image-exiftool Usage Link to heading exiftool -overwrite_original_in_place -all= path-to-file

  47. Convert PDF to PNG and back

    Prerequisites Link to heading sudo pacman -S gimp imagemagick poppler PDF to PNG Link to heading Create a directory with your INITAIL.pdf then execute this inside of it: pdftoppm INITIAL.pdf prefix-for-images -png Do whatever Link to heading Edit your i…

  48. Enable systemd-oomd

    Prerequisites Link to heading Make sure you have systemd installed with at least version 248: pacman -Ss systemd | grep "core/systemd " # core/systemd 248.2-1.1 [installed] Setup Link to heading Check if the service is active: systemctl status systemd-o…

  49. Emacs Lisp interactive debugging

    Navigate to your function.

  50. Replace string in all files with sed

    find .