Skip to content

Instantly share code, notes, and snippets.

@andreoss
andreoss / decolorize
Created April 18, 2021 23:01
Decolorize output
#!/usr/bin/env --split-string=perl -p
s/ \x1B [ @ A-Z \\ \] ^_ ] //gx;
s/ \x1B \[ [0-9 : ; < = > ? ]{1,8} \W? [@ A-Za-z ^_\` {|} ~]? //gx;
@andreoss
andreoss / lombok.config
Created April 15, 2021 04:46
Lombok configuration for Spring, makes contructor injection work with annotations
lombok.addLombokGeneratedAnnotation = true
lombok.anyConstructor.addConstructorProperties=true
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Autowired
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Value
@andreoss
andreoss / toggle-touchpad
Created April 8, 2021 04:27
Toggle touchpad/trackpoint/mouse
#!/bin/sh
set -u
list_all_ids() { xinput list --id-only; }
device_by_id() { xinput list --short "$1";}
device_property() {
xinput list-props "$1" | while read -r prop
do
case "$prop" in
*"$2"*:*[01])
echo "${prop#*:}" | xargs
find src -name '*.java' -exec perl -i -nE 'print unless /[@](version|author)/' {} \+
find src -name '*.java' -exec perl -i -007 -pE 's{^/[*][*]}{/*}' {} \;
@andreoss
andreoss / clear-utf8.pl
Created November 25, 2020 16:26
Remove >3 bytes characters
#!/usr/bin/env perl
use strict;
use warnings;
use open qw( :encoding(UTF-8) :std );
use English qw( -no_match_vars );
while ( my $line = <> ) {
my $count = $line =~ s{
[\N{U+07FF}-\N{U+7FFFFFF}]
} [?]xg;
@andreoss
andreoss / emacs.nix
Created October 31, 2020 23:20
Lucid Emacs
{ pkgs ? import <nixpkgs> {} }:
let
emacs_ = (pkgs.unstable.emacs.override {
withGTK3 = false;
withGTK2 = false;
}).overrideAttrs (attrs: {
configureFlags = [
"--disable-build-details"
"--with-modules"
@andreoss
andreoss / .mini.el
Last active October 12, 2020 21:37
Minimal vi-like Emacs configuration without extra modules
;;; Commentary:
;;; Minimal vi-like Emacs configuration.
;;;
;;; $ emacs -Q -nw -l mini.el
;;;
;;; Code:
;; Visual bell
(setq-default visible-bell t)
;; Do not display mode-line
(setq-default mode-line-format nil)
find src/test/ -name '*Test.java' -o -name '*ITCase.java' -exec perl -007 -i -pE 'unless($_ =~ /@Test\(expected/xgsm || $_ =~ /@(Class)?Rule/xgsm) { s/^public final class/final class/sgm; s/@Test^\s{4}public void/ void/sgm; s/org.junit.Test/org.junit.jupiter.api.Test/}' {} \;
find . -name '*.java' -exec perl -007 -nE '/(?<=class\s)(\S+?)([A-Z][a-z]+?)(?:Impl)?\s/ && say $2' {} \+ | sort | uniq -c | sort -rn |head -8
import org.junit.Assert;
final class Loop extends Exception {
Loop(long max, Iter iter) throws Exception {
super(iter);
try {
Assert.assertTrue(max > 0);
throw new Loop(max - 1, new Iter(iter));
} catch (final AssertionError fal) {
throw new Exception(iter);
}