Skip to content

Instantly share code, notes, and snippets.

# File hashes
function md5sum { Get-FileHash -Algorithm MD5 $args }
function sha1sum { Get-FileHash -Algorithm SHA1 $args }
function sha256sum { Get-FileHash -Algorithm SHA256 $args }
# Equivalent of bash `ll` alias
function ll { Get-ChildItem -Force @args }
@carlosame
carlosame / volumekeys.ahk
Created January 12, 2022 19:29
Finer-grained Windows volume keys AutoHotkey script
; Finer-grained Windows volume keys AutoHotkey script
;
; See https://www.autohotkey.com/ for info about AutoHotkey
;
; Volume Up/Down keys use increments/decrements
; of 2 if volume is above 6, 1 if below.
#SingleInstance Force
$Volume_Up::
@carlosame
carlosame / generate_directory_index_caddystyle.py
Last active August 16, 2023 13:10 — forked from glowinthedark/generate_directory_index_caddystyle.py
Generate directory index (recurse subfolders with `-r` or `--recursive`). Use `-h` or `--help` for all options
#!/usr/bin/env python3
# ---
# Copyright 2020 glowinthedark
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
@carlosame
carlosame / gradle-module-info.md
Last active December 1, 2021 15:11
Compile 'module-info' separately in Gradle

Compile module-info separately in Gradle

To make projects compatible with both Java 8 and modular JDKs, a popular strategy is to compile the project so it produces Java 8 bytecode, and separately compile the module-info.java file targeting a modular JDK version.

The Apache Maven documentation includes an example of how to achieve that, but the Gradle user guide lacks it. This document presents an approach that could be included in a convention plugin, and requires Gradle 7 or higher (you could try to adapt it to Gradle 6.x by explicitly enabling inferModulePath in

@carlosame
carlosame / css-assign-mechanism.md
Created March 17, 2021 16:43
Compact CSS media rules: the 'assign' mechanism

Compact CSS media rules: the @assign mechanism

Justification

As mentioned in my gist about a CSS switch-like function, authors would like to have a mechanism for less verbose CSS @media rules, as expressed in CSSWG's issue 5009.

In that issue a possible new syntax (with a few variants) is suggested, with authors specifying stacked property values that

@carlosame
carlosame / css-switch-like-function.md
Last active March 20, 2021 15:32
A switch-like function for CSS

A switch-like function for CSS

Rationale

In CSS, @media rules are useful but may lead to some unwanted verbosity and maintenance issues. Although var() values are of help, one often has to either duplicate some rule structure or proliferate custom properties that are intended to be used at specific places. That's what CSSWG's issue 5009 is about.

Due to that, sometimes authors would prefer to specify values at the place where they are going to be used in the most common

@carlosame
carlosame / enhance-git-bash.md
Last active April 30, 2024 02:16
Install additional commands on Git Bash (Windows 10)

Install additional commands on Git Bash (Windows 10)

This assumes that your Git Bash is using MSYS instead of Cygwin (look at the output of uname -o if you are in doubt). If you are using Cygwin, please refer to standard Cygwin procedures.

  1. Open http://repo.msys2.org/msys/x86_64/ (or one of the mirrors at https://github.com/msys2/MSYS2-packages/blob/master/pacman-mirrors/mirrorlist.msys) and download the commands that you want to add.
  2. Extract the content of the package that you want to install to a working directory. For example,
    mkdir tmp
    cd tmp
 tar xf ../libzstd-1.4.5-2-x86_64.pkg.tar.xz
@carlosame
carlosame / maven-dependency-version-ranges.md
Created July 14, 2020 13:00
Maven dependency version ranges for libraries

Maven dependency version ranges

Introduction

Java:tm: projects generally depend on other projects, and those dependencies are detailed in the file that describes how to build the project, often the Maven POM.

The build process needs to know which version or versions of the dependencies are required to succeed, and projects often specify a single, fixed version, perhaps the same one that was used when the project's code was edited with the help of an IDE. In the Maven POM, this is done by introducing a line like:

1.7.28