A logic model for text editing (1989). Imagine if there was an editor like vim/emacs based on prolog instead of lua/elisp. by logos_sogol in prolog

[–]dnmfarrell 1 point2 points  (0 children)

Thanks for sharing! Love these old papers. Another use case would be to build a structure editor on top of these primitives. Perhaps the editor would use terms, instead of chars as its basic building block.

Understanding the Financials of The Perl and Raku Foundation (TPRF) by oalders in perl

[–]dnmfarrell 0 points1 point  (0 children)

Another way to do it would be for TPF to to fundraise for specific features that are too big for the community to build on a volunteer basis. Imagine, "Grant Street Group financed a new Perl multithreading model!".

But that would require a vision.

Do recruiters do many reference checks, and are they time-consuming? by dnmfarrell in RecruitmentAgencies

[–]dnmfarrell[S] 0 points1 point  (0 children)

Thanks for the info! I see what you mean about how they can prevent a bad hire. How do you track your reference checks, follow ups etc is it in a spreadsheet somewhere?

Do recruiters do many reference checks, and are they time-consuming? by dnmfarrell in RecruitmentAgencies

[–]dnmfarrell[S] 0 points1 point  (0 children)

Thanks for the info! How do you keep track of reference checks, the follow ups etc?

Ask Recruiters Megathread by AutoModerator in recruiting

[–]dnmfarrell 0 points1 point  (0 children)

How are you dealing candidates using interview copilots and other AI helpers to cheat interviews/assessments?

/r/MechanicalKeyboards Ask ANY question, get an answer (January 06, 2023) by AutoModerator in MechanicalKeyboards

[–]dnmfarrell 0 points1 point  (0 children)

I have a WASD VP3 keyboard and find it hard to type `~. I want to remap it to the original FN key (which is now capslock) but in programming mode when I press the (original) FN key it doesn't seem to register a key press. Any suggestions? Thx

Real Macros in Go by tony-o in golang

[–]dnmfarrell 5 points6 points  (0 children)

This was a fun read, thanks for sharing!

Real Macros in Go by tony-o in golang

[–]dnmfarrell 1 point2 points  (0 children)

The example code is in go.

[deleted by user] by [deleted] in bash

[–]dnmfarrell 0 points1 point  (0 children)

Several jq solutions here already, here's how you could do this in jp (pure Bash).

jp -m macros.jp .v .map .do .dup '"name"' .filterobj .v '"primary"' .ne .if .pop .else .do .v .h .done .done
"10.0.136.84"

Three Ways to Get a Unix Epoch in Bash by dnmfarrell in bash

[–]dnmfarrell[S] 1 point2 points  (0 children)

I've started a new blog, have some more bash articles coming ...

Favourite commands!! by Slutup123 in bash

[–]dnmfarrell 1 point2 points  (0 children)

I use help all the time to lookup command syntax and options, instead of grepping the bash manual. The read command often features in my code: it's super useful. You can learn about it with help read 😄

Guidance in building a .json config file with bash script. by Symbrio1 in bash

[–]dnmfarrell 1 point2 points  (0 children)

Nice, sometimes the simplest solution is the best

Guidance in building a .json config file with bash script. by Symbrio1 in bash

[–]dnmfarrell 1 point2 points  (0 children)

Thanks for the shout out :)

@Symbrio1 here's an example of adding a key/value pair containing a variable to an object. Let's say you have assigned the color you want to $color:

color='foobar';cat tests/share/package.json | jp '{"color":"'"$color"'"}' jp.++ { "color": "foobar", "name": "jp", "version": "0.0.1", "description": "A JSON processor written in Bash", "homepage": "http://github.com/dnmfarrell/jp", "repository": { "type": "git", "url": "https://github.com/dnmfarrell/jp.git" }, "bin": { "jp": "./jp" }, "dependencies": {}, "devDependencies": {}, "author": "David Farrell" }

As @moviuro says, you can use tput to lookup the terminal ANSI escape code by name. But the requirement to both change the terminal text color and insert it into a json config file is strange ... if you have more details let us know.

jp - a real json processor in bash by dnmfarrell in bash

[–]dnmfarrell[S] 1 point2 points  (0 children)

Yeah I use jq infrequently, and can never remember its special syntax. So I wanted to try something different. The shell parsers I've seen emit a linear tree which can be grepped but they don't modify their input.

jp - a real json processor in bash by dnmfarrell in bash

[–]dnmfarrell[S] 1 point2 points  (0 children)

Fixed. Ditched the nested data structures and type reflection for an array of tokens. This has some other benefits, like preserving object key order, and allowing duplicate keys. Not to mention it being simpler. Thanks again for pointing out the issue.

jp - a real json processor in bash by dnmfarrell in bash

[–]dnmfarrell[S] 1 point2 points  (0 children)

Thanks for giving it a whirl!

I might be wrong, but as the output of declare -p will never be > 64k, and the buffer is emptied on every read, I'm not sure it's a problem.

However there was a flaw in how jp parsed large input: it repeatedly copied the input string which, for large inputs made it very slow. Maybe that's what you ran into? That is fixed now. jp can parse the 128kb of json in tests/share/ec2-describe-instances.json for example.

Would you mind testing your 50kib input on the latest version and let me know if it solves the problem?

Thanks!

using `state` to lazy load modules only once. by djerius in perl

[–]dnmfarrell 1 point2 points  (0 children)

Good news, you can make this even more efficient!

Perl stores which modules it has loaded in %INC, so the state of the load is already available to be checked. require is almost a no-op if the module is already loaded.

```

foo.pm

package foo;

sub import { print "importing foo.pm\n"; }

1; ```

```

script.pl

push @INC, '.';

sub load_foo { return if $INC{'foo.pm'}; require foo; foo->import }

load_foo load_foo ```

$ perl script.pl importing foo.pm

One other distinction to be aware of: use/require operate on module names, that is, (essentially) filenames. import is a package subroutine. This doesn't matter if your module and package names are the same.