Skip to content

Instantly share code, notes, and snippets.

@ozzm
ozzm / generate-hash.md
Last active January 10, 2025 01:53
[How to generate hash of file using OpenSSL] #openssl

Cryptographic hash functions can be used for verifying file integrity. To check that the file has not been altered during transfer over the network.

Let's say we have the following file named data.txt with the following content:

Hello world

The openssl dgst command can be used to perform various digest operations.To generate a hash of the file data.txt using SHA-256, run the following command:

@ozzm
ozzm / .editorconfig
Created May 28, 2023 19:20
[Editor Config] .editorconfig #dotfiles
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@ozzm
ozzm / .curlrc
Created May 28, 2023 19:18
[curl] .curlrc #dotfiles
-w "\nstatus=%{http_code} %{redirect_url} size=%{size_download} time=%{time_total} content-type=\"%{content_type}\"\
insecure
insecure
@ozzm
ozzm / alacritty.yml
Created May 28, 2023 19:07
[Alacritty] #config
# https://clubmate.fi/alacritty
# ~/.config/alacritty/alacritty.yml. -- linux
# %APPDATA%\alacritty\alacritty.yml -- windows
window:
# Blank space added around the window in pixels. This padding is scaled
# by DPI and the specified value is always added at both opposing sides.
padding:
x: 10
y: 10
@ozzm
ozzm / treefmt.md
Last active May 28, 2023 14:42
[Treefmt] a tool to format all your project files at once #tools

How to use treefmt in a nix build

{ src # src should point to the project to check the format for
, runCommandNoCC
, shfmt
, rustfmt
, treefmt
}:
@ozzm
ozzm / random-list-of-strings.py
Last active May 25, 2023 07:55
[Generate random string] Generate a list of 10 lower case random 4 letter strings #python
#
import string
import random
# Generate a list of 10 lower case random 4 letter strings
result_str = string.ascii_lowercase
random_strings = []
@ozzm
ozzm / pdfsplit.sh
Last active October 24, 2023 14:20
[PDF Split] #ghostscript #bash_functions
#!/bin/sh
#
# pdfsplit [input.pdf] [first_page] [last_page] [output.pdf]
#
# Example: pdfsplit big_file.pdf 10 20 pages_ten_to_twenty.pdf
#
# written by: Westley Weimer, Wed Mar 19 17:58:09 EDT 2008
#
# The trick: ghostscript (gs) will do PDF splitting for you, it's just not
# obvious and the required defines are not listed in the manual page.
@ozzm
ozzm / load-variables-from-dotenv-files.sh
Last active June 11, 2023 16:26
[Load Variable from .env file] #shell
#!/bin/sh
#
# Load variables from '.env' files
#
# Usage:
#
# To inject '.env' variables and run a command:
# dotenv my_command param1 param2
#
@ozzm
ozzm / backup-database-and-copy-to-remote
Last active June 11, 2023 16:26
[Backup database and copy to remote] #shell
#!/bin/bash
# source:
# https://gist.github.com/fideloper/2649884
# THIS VERSION WILL ASK YOU FOR THE DATABASE NAME AND WHERE TO SAVE IT LOCALLY
function show_usage {
echo "Usage: $0 database-name save-directory"
exit 1
@ozzm
ozzm / bash-cheatsheet.sh
Last active June 11, 2023 16:27
[Bash Cheatsheet] #shell
#!/bin/bash
# source:
# https://github.com/LeCoupa/awesome-cheatsheets/blob/master/languages/bash.sh
##############################################################################
# SHORTCUTS
##############################################################################
CTRL+A # move to beginning of line