Skip to content

Instantly share code, notes, and snippets.

@andreoss
andreoss / .editorconfig
Last active October 23, 2020 17:21
Qulice-compliant .editorconfig
[*]
charset = utf-8
end_of_line = lf
tab_width = 4
indent_size = 4
indent_style = space
insert_final_newline = false
max_line_length = 80
ij_visual_guides = 80
ij_wrap_on_typing = true
@andreoss
andreoss / fib
Created June 26, 2020 02:25
tail recursive and cached
#!/bin/sh
_() { echo $(awk 'END{x=$2;$2=$3;$3=x+$2;print}' < "$0")| tee -a "$0" ; }
: 0 1 | _
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);
}
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
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/}' {} \;
@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)
@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 / 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;
find src -name '*.java' -exec perl -i -nE 'print unless /[@](version|author)/' {} \+
find src -name '*.java' -exec perl -i -007 -pE 's{^/[*][*]}{/*}' {} \;
@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