← Înapoi la Urmăritori

Cel mai recent articol

Ultima verificare

Urmăritori 0 urmăritori
Articole: 137
  1. Set up a console for Ruby projects

    With IRB Link to heading Add irb to your Gemfile (yes you need to do this)!

  2. To set up Gemfile functionality do this: #!

  3. Ruby Minitest and Simplecov starter

    Add these gems to your Gemfile: # frozen_string_literal: true group :development, :test do gem 'minitest' gem 'rake' gem 'simplecov' end Run bundle install to install them.

  4. Quick way to format numbers in Ruby

    number = 12345678 number.to_s.gsub(/\B(?

  5. Generate a good SSH key

    The proper one Link to heading If you don’t have any keys, generate a default one: ssh-keygen -t ed25519 -a 100 -q -N "" -f ~/.ssh/id_ed25519 And if you want it generated in the current directory do: ssh-keygen -t ed25519 -a 100 -q -N "" -f "$PWD"/rename…

  6. Docker Images: Firefox with Geckodriver

    # ------------------------------------------------------------------------------ # Base FROM alpine:3.12.1 # ------------------------------------------------------------------------------ # Packages RUN set -exo pipefail && \

  7. One Liners: Generate random password

    Basic command: tr -dc "a-zA-Z0-9" < /dev/urandom | head -c 32 Print it to STDOUT: echo $(tr -dc "a-zA-Z0-9" < /dev/urandom | head -c 32) Save it in an environment variable: export SECRET_PASSWORD=$(tr -dc "a-zA-Z0-9" < /dev/urandom | head -c 32)

  8. Easter Eggs: Firefox

    Start the console with Ctrl + Shift + K Run: document.designMode = 'on' Close the console with Ctrl + Shift + I And now you can edit any text directiny into the page.

  9. Temporary files and directories in Ruby

    File Link to heading Create a temporary file in your current directory: require 'tempfile' Tempfile.create('', Dir.pwd) do |file| puts File.path(file) File.write(file, 'I am temporary!')

  10. Pretty Printing in ruby

    Say you have a complex object like: state = {a: 1, b: '2', c: [3, 4, 5]} And you want to display it nicely to standard output.

  11. How to Use: inxi

    Want to show somebody your hardware/OS specs?

  12. Basic Makefile starter

    Use this template as a sterter for your Makefile, making sure you intent using tabs as that’s a hard requirement of the make tool. #------------------------------------------------------------------------------- # Settings #-------------------------------…

  13. Docker Images: basic Ruby setup

    Use this as a template for ruby apps: #------------------------------------------------------------------------------- # Base FROM ruby:2.7.2-alpine SHELL ["/bin/ash", "-c"] #-----------------------------------------------------------------------------…

  14. Docker Images: basic entrypoint

    This is a docker entrypoint script that loads environment variables from a mounted file and executes the given command; most of the time it’s all you need. #!

  15. Serve HTML files with Ruby

    Python has: python3 -m http.server But I like Ruby, so I do this instead: # Basic: ruby -run -e httpd # With arguments: ruby -run -e httpd -- -b 0.0.0.0 -p 9090 Note: there is no such thing as a -run flag for ruby, you’re doing -r for require and you’re

  16. Easter Eggs: ruby

    Ruby is amazing!

  17. How to Use: docker-here

    Source: https://gitlab.com/sdwolfz/docker-here Install Link to heading git clone https://gitlab.com/sdwolfz/docker-here.git cd docker-here sudo make install Usage Link to heading Instead of doing this: docker run --rm -it -u "$(id -u)":"$(id -g)" -v "$PW…

  18. How to configure Git properly

    Required Link to heading You need a name and email otherwise commits won’t work: git config --global user.name 'Your Name' git config --global user.email 'your.email@faang.com' Global .gitignore Link to heading Don’t put junk like these in your poject’s…

  19. Fix font issues in Snaps

    Website: https://snapcraft.io Snaps are amazing, I don’t understand why people hate them, tell me another way you can reliably install and update apps like these with a single command: acrordrdc (Adobe Acrobat Reader) androidsdk (Android SDK) drawio (Diag…

  20. How to Use: yamllint

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

  21. How to Use: shellcheck

    Install Link to heading From package: # Manjaro / Arch sudo pacman -S shellcheck # Alpine apk add --update shellcheck From Docker: docker run --rm -it -v "$PWD":/work -w /work koalaman/shellcheck-alpine:latest sh Configure Link to heading Add a .shellc…

  22. How to Use: hadolint

    Install Link to heading It’s not available in any package manager, so use the Docker image: docker run --rm -it -v "$PWD":/work -w /work hadolint/hadolint:latest-alpine sh Configure Link to heading Add a .hadolint.yaml file containing your rules: --- ig…

  23. Reuse YAML sections with anchors

    Define an anchor using the & character and reference it everywhere using the <<: * alias: version: '2.4' x-default-logging: &logging logging: options: max-size: '12m' max-file: '5' driver: json-file services: web: image: alpi…

  24. How to Use: envsubst

    Install Link to heading # Manjaro / Arch sudo pacman -S gettext # Alpine apk add --update gettext Usage Link to heading Create a template input file .

  25. How to Use: editorconfig

    This is editorconfig: https://editorconfig.org This is the checker: https://github.com/editorconfig-checker/editorconfig-checker Install Link to heading The CLI tool: # Manjaro / Arch sudo pacman -S git editorconfig-checker # Alpine apk add --update git…

  26. Ruby string interpolation

    The bad way: count = 3.to_s puts 'I ate ' + count + ' burgers today!'

  27. Compile Android projects from CLI

    Install java: sudo pacman -S jdk8-openjdk jre8-openjdk jre8-openjdk-headless Install Android SDK: sudo pacman -S snapd sudo snap install androidsdk Configure your SDK location in your ~/.bash_profile or ~/.bashrc: export ANDROID_SDK_ROOT=~/snap/androids…

  28. How to configure your Bash history

    Good Link to heading export HISTCONTROL=ignoreboth:erasedups export HISTSIZE=5000000 export HISTFILESIZE=5000000 export HISTFILE=/home/$USER/.bash_history_persistent shopt -s histappend export PROMPT_COMMAND="history -a; $PROMPT_COMMAND" It’s crucial th…

  29. How to Use: pry-byebug

    Add the pry-byebug gem, together with irb, to your Gemfile: group :development, :test do gem 'irb' gem 'pry-byebug' end Add a .pryrc file to your project containing: # frozen_string_literal: true if defined?

  30. Install Cask from source

    Prerequisites Link to heading Install Emacs Install Link to heading Clone and link the repository: git clone https://github.com/cask/cask.git rm -rf ~/.cask ln -s "$PWD"/cask ~/.cask Add this to your .bash_profile: export PATH=~/.cask/bin:$PATH Install…

  31. Install Ruby gems in home directory

    Create the ~/.gemrc file with the following content: gem: --no-rdoc --no-ri --user-install Add these lines to your .bash_profile: for entry in ~/.gem/ruby/*; do PATH=$entry/bin:$PATH; done export PATH export BUNDLE_PATH=~/.gem/bundle Now you can install

  32. Install NPM packages in home directory

    Create the ~/.npmrc file with the following content: prefix = "~/.local" Add the following line to your .bash_profile: export PATH=~/.local/bin:$PATH Now you can install a npm package without your root password: npm install -g eslint which eslint # /ho…

  33. How to Use: restclient

    Setup Link to heading Add the restclient layer to your .spacemacs: dotspacemacs-configuration-layers '( restclient ) Secrets Link to heading Define the following function in your dotspacemacs/user-config: (defun restclient-envchain-get (namespace varia…

  34. How to Use: fzf

    Install Link to heading sudo pacman -S fzf Setup Link to heading Add the following lines to your .bash_profile: [[ -f /usr/share/fzf/completion.bash ]] && .

  35. Linear regression in Ruby

    Let’s say you have the following 5 numbers: values = [100, 200, 300, 400, 500] To predict the next 3 in this series you need linear regression: def linear_regression(pairs) n = pairs.size sum_x = pairs.map { |x, _| x }.sum.to_f sum_y = pairs.map {…

  36. How to Use: envchain

    Install Link to heading git clone https://github.com/sorah/envchain.git cd envchain make sudo make install Usage Link to heading Store a new environment variable with the following command, adding the value after the prompt: envchain -s -n namespace MY_N…

  37. Install Emacs from source

    Prerequisites Link to heading sudo pacman -S libgccjit Compile Link to heading git clone git://git.sv.gnu.org/emacs.git cd emacs .