[-] sebastiancarlos 6 points 1 day ago

mother can be used in several ways. If both X and Y variables are uninitialized, then it looks for all mother relationships. If one of them is initialized, it looks for matching relationships. If both are initialized, it returns true if such a relationship exists.

[-] sebastiancarlos 6 points 1 day ago* (last edited 1 day ago)

Depends on how you want to define your domain knowledge.

The thing you need to define for sure is the predicate mother/2 (Which has arity 2, or in other words, two arguments). From then on, multiple options are available:

  1. Take mother(X, Y) as an "axiom", and define mother terms for all elements:
mother(abel, eve).
mother(isaac, sarah).
  1. Derive mother(X, Y) from female(X) and parent(X, Y) terms.
mother(X, Y) :- 
  parent(X, Y), 
  female(Y).
  1. Smash the institutional gender power structures and define only parent/2 terms instead of mother/2 and father/2.
38

something is a person if it is either Adam or Eve, or if it has a mother. We can express this in a single rule as follows:

person(X) :- (X=adam; X=eve; mother(X, Y)).

231

Hey everyone,

So, I was doing some last-minute Christmas shopping and thought I scored a deal on a Nintendo Switch for my nephew. Turns out, I didn’t read the description carefully enough, and I ended up with a NETGEAR 16-Port Gigabit Ethernet Managed Switch.

To be fair, it does look like a futuristic game console.

After some initial panic, I’ve decided to just keep it. Who knows? Maybe one day I’ll pivot into the hotel business and need to save on network infrastructure costs. Gotta think long-term, right?

68
The Piano Axioms in Prolog (self.programmerhumor)
submitted 1 week ago* (last edited 1 week ago) by sebastiancarlos to c/programmerhumor@lemmy.ml
% Piano Axioms

% Axiom 1: Law of Excluded Gray
key_type(white).
key_type(black).

% Axiom 2: The C Postulate
key_color(c, white).

% Axiom 3: The Diatonic Scale
next_white_key(c, d).
next_white_key(d, e).
next_white_key(e, f).
next_white_key(f, g).
next_white_key(g, a).
next_white_key(a, b).
next_white_key(b, c).

% Axiom 4: The Semitone Anomaly
semitone_gap(e, f, 1).
semitone_gap(b, c, 1).
semitone_gap(X, Y, 2) :- 
    next_white_key(X, Y),
    X \= e,
    X \= b.

% Axiom 5: Black Key Entropy
has_black_key_between(X, Y) :-
    next_white_key(X, Y),
    semitone_gap(X, Y, 2).

% Axiom 6: The "8 is 12" Principle.
octave_size(12).

% Axiom 7: Out of Bounds Exception
total_keys(88).

% Theorem 1: Conservation of "Wrong Notes"
style(jazz) :-
    wrong_notes > 0,
    write('All wrong notes are now intentional').
168
submitted 1 week ago* (last edited 1 week ago) by sebastiancarlos to c/programmerhumor@lemmy.ml

How to write a programming novel?

  • Cover: CSS
  • Copyright Page: GNU GPLv3
  • Intentionally Blank Page: Whitespace
  • Notes For The Second Edition: Kotlin
  • Notes for The First Edition: Java
  • Front Matter: Markdown
  • Dedication: Rust
  • Prologue: Prolog
  • Chapter 1: C
  • Chapter 2: C++
  • Chapter 3: C3
  • Chapter 4: Forth
  • Pull Quotes: Git
  • Unexpected Sex Scene: LaTeX
  • Dream Sequence: APL
  • Cliffhanger Ending: Python 2
  • Index: IndexedDB
  • Errata: PHP
  • Sequel: SQL
150
submitted 1 month ago by sebastiancarlos to c/programmerhumor@lemmy.ml
class BaseFunction {
  static #allowInstantiation = false;

  constructor(...args) {
    if (!BaseFunction.#allowInstantiation) {
      throw new Error(
        "Why are you trying to use 'new'? Classes are so 2015! Use our fancy 'run' method instead!"
      );
    }
    for (const [name, validator] of this.parameters()) {
      this[name] = validator(args.shift());
    }
  }

  parameters() {
    return [];
  }

  body() {
    return undefined;
  }

  static run(...args) {
    BaseFunction.#allowInstantiation = true;
    const instance = new this(...args);
    BaseFunction.#allowInstantiation = false;
    return instance.body();
  }
}

class Add extends BaseFunction {
  parameters() {
    return [
      ["a", (x) => Number(x)],
      ["b", (x) => Number(x)],
    ];
  }

  body() {
    return this.a + this.b;
  }
}

console.log(Add.run(5, 3)); // 8



12
Makefiles For Threesomes (sebastiancarlos.com)
submitted 2 months ago by sebastiancarlos to c/programmerhumor@lemmy.ml
[-] sebastiancarlos 18 points 3 months ago* (last edited 3 months ago)

Totally understand your perspective, and I’m not here to push back against it. You’ve got a valid point.

I’ll just add that there are already commercial tools that do similar things to what I’m building. It’s interesting to consider how perceptions might shift if a tool were released by a company rather than a solo developer. Sometimes the context influences how a tool is interpreted, even if the underlying functionality remains the same. For what it’s worth, I have no commercial intent behind this.

[-] sebastiancarlos 21 points 3 months ago

Hey, thanks for the comment. I get that it might be used for something shady, but that’s not the intention. The primary goal is to clean up raw time-tracking data into a format that’s easy to present to clients or supervisors, especially for contexts when small gaps or irregularities should be absent.

I imagine most professionals aren’t expected to account for every single minute of their workday. For example, if you’re switching tasks or taking short breaks. It’s more about reporting general productivity or overall progression of tasks, not trying to inflate hours.

Anyone aiming for 'time fraud' could probably find easier methods. My focus is to make life easier for people who already track their work but want cleaner, more digestible reports.

Appreciate the feedback though, helps me make sure the use case is clear! :)

228
submitted 3 months ago by sebastiancarlos to c/linux@lemmy.ml

It's almost done (it would take one or two weeks to clean it up for FOSS release). It's a CLI tool. It works great for my use case, but I'm wondering if there's any interest in a tool like this.

Say you have a simple time-tracking tool that tracks what you do daily. The only problem is that there are gaps and whatnot, which might not look nice if you need to send it to someone else. This tool fixes pretty much all of that.

Main format is a JSON with a "description", and either "duration" or a "start"/"end" pair. It supports the Timewarrior format out of the box (CLI Time tracking tool).

-29
submitted 4 months ago by sebastiancarlos to c/programmerhumor@lemmy.ml
164
submitted 4 months ago by sebastiancarlos to c/programmerhumor@lemmy.ml
126
submitted 5 months ago* (last edited 5 months ago) by sebastiancarlos to c/linux@lemmy.ml

Either self-hosted or cloud, I assume many of you keep a server around for personal things. And I'm curious about the cool stuff you've got running on your personal servers.

What services do you host? Any unique stuff? Do you interact with it through ssh, termux, web server?

328
submitted 5 months ago by sebastiancarlos to c/programmerhumor@lemmy.ml
29
submitted 6 months ago* (last edited 6 months ago) by sebastiancarlos to c/linux@lemmy.ml

Hey,

As an avid CLI user, I always aimed to master non-interactive tools to perform most of my work, given that they are easy to use, create, extend, and connect.

However, I found myself dealing with software projects with many files (mostly under the yoke of corporate oppression; an ordeal which I endure to sustain myself, as most of those reading me do, and therefore I will not go further into this topic) and started to hit the limits of non-interactive tools to find and edit files. Indeed, I could go faster if I followed the temptation of monstrous IDEs, as I did in my innocent past.

I did not despair, as naturally I heard of the usefulness of interactive fuzzy finders such as fzf. After spending an afternoon evaluating the tool, I concluded that it indeed increases the complexity of my workflow. Still, this complexity is managed in a sensible way that follows the UNIX tradition.

I now ask you two general questions:

  • Did you reach similar conclusions to me and decide to use interactive fuzzy finders to solve working on software projects with many files?
  • If you use fzf or similar tools, what can you tell me about your workflow? Any other third-party tools? Do you integrate it into your scripts? Any advice that you can give me out of a long time of experience using the tool that is not easily conveyed by the documentation?

I also ask this very specific question:

  • The one part of fzf which I found missing was a way to interact with the results of grep, and to automatically place the selected file(s) in the prompt or an editor. For that, I created the following two commands. Do you have a similar workflow when you want to bring the speed of fuzzy finding to grep?
#! /usr/bin/env bash

# gf: grep + fzf
# basically a wrapper for 'grep <ARGS> | fzf | cut -f 1 -d:'

# print usage on -h/--help
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
    echo "Usage: gf <grep-args>"
    echo
    echo "~~~ that feel when no 'gf' ~~~"
    echo
    echo "- Basically a wrapper for 'grep <ARGS> | fzf | cut -f 1 -d:'"
    echo "- Opens fzf with grep results, and prints the selected filename(s)"
    echo "- Note: As this is meant to search files, it already adds the -r flag"
    echo
    echo "Example:"
    echo "  $ nvim \`gf foobar\`"
    echo "  $ gf foobar | xargs nvim"
    exit 0
fi

# run grep with arguments, pipe to fzf, and print the filename(s) selected
custom_grep () {
    grep -E --color=always --binary-files=without-match --recursive "$@"
}
remove_color () {
    sed -E 's/\x1b\[[0-9;]*[mK]//g'
}
custom_fzf () {
    fzf --ansi --height ~98%
}
grep_output=$(custom_grep "$@")
if [[ "$?" -ne 0 ]]; then
    exit 1
else
    echo "$grep_output" | custom_fzf | remove_color | cut -f 1 -d:
fi
#! /usr/bin/env bash

# ge: grep + fzf + editor
# basically a wrapper for 'grep <ARGS> | fzf | cut -f 1 -d: | $EDITOR'

# print usage on -h/--help
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
    echo "Usage: ge <grep-args>"
    echo
    echo "- Basically a wrapper for 'grep <ARGS> | fzf | cut -f 1 -d: | \$EDITOR'"
    echo "- Opens fzf with grep results, and edits the selected file(s)"
    echo "- Note: As this is meant to search files, it already adds the -r flag"
    echo "- Note: Internally, it uses the 'gf' command"
    echo
    echo "Example:"
    echo "  $ ge foobar"
    exit 0
fi

# takes output from 'gf' and opens it in $EDITOR
grep_fzf_output=$(gf "$@")
if [[ -n "$grep_fzf_output" ]]; then
  $EDITOR "$grep_fzf_output"
fi

Have a wonderful day, you CLI cowboys.

[-] sebastiancarlos 13 points 8 months ago* (last edited 8 months ago)

Tbh these scripts are for my personal use, written in the way that makes sense for me. I only open sourced it as a joke an as an example of how reinventing your own wheel is not that hard sometimes, and comes with the benefit of doing just what you need it to do.

Actually I was thinking of adding a sysget fallback, as I might need to do some debian/fedora hacking soon.

[-] sebastiancarlos 65 points 1 year ago

The joke is that it's hard to tell if this is a joke because the lines between good intentions, corporate jargon, and feasibility have been blurred beyond recognition both here and in the real world.

It's also funny that after all these years, i18n is still a mess. Moreover, even if translations are standard in GUIs and documentation, for some reason, everyone is okay with defaulting to English for the oldest form of computer interaction.

Also, the joke is whatever you want it to be. Follow your dreams.

[-] sebastiancarlos 25 points 1 year ago

It's also traditional to eat raw meat, but we discovered fire at some point.

[-] sebastiancarlos 30 points 1 year ago* (last edited 1 year ago)

You also don’t need the dash for the short options.

True, but I refuse to entertain such a non-standard option format. It's already enough to tolerate find's.

[-] sebastiancarlos 14 points 1 year ago
[-] sebastiancarlos 15 points 1 year ago

it's surely one of the CSS lines of all time

[-] sebastiancarlos 37 points 1 year ago
[-] sebastiancarlos 22 points 2 years ago

It's a parody of the hype around AI, particularly the "AI discovers faster sorting algorithm" news from last week. Full (satirical) source.

view more: next ›

sebastiancarlos

joined 2 years ago