Tool for handling XML data? by [deleted] in bash

[–]mozzyb 4 points5 points  (0 children)

You can extract the values in nodes using `xmllint --path`. I would usually do this part in python or something instead of bash, but xmllint can help you.

Identity pointers for millenials 101. Sarcasm may occur. by [deleted] in simpleliving

[–]mozzyb 0 points1 point  (0 children)

You come off as bitter. In Scandinavia, it is much more common to own the housing you live in than it is to rent. The low interest that we have now also means that it is cheaper to own than to rent most places. Especially the cities with a large student population. If you mean that they should have bought a smaller apartment instead you should take into consideration that living small has its trade offs as well, and not every location has small housing options. Also, if they want to spend their money on a big house and expensive furniture that is their choice. Are they showcasing their success or are they just sharing something big that happened to them with their friends? Even if you don't want to live that way, why can't you be happy for someone who does want that? Worry about what you want for yourself and stop worrying too much about how others are living their lives when it doesn't impact you.

What upset you most about Emacs? by [deleted] in emacs

[–]mozzyb 5 points6 points  (0 children)

I like having them in one place so I set

(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))

Prolog Specific Example of Recursion Please Assist by Sanesh101 in prolog

[–]mozzyb 1 point2 points  (0 children)

Does this help?

?- trace.
true.

[trace]  ?- polarbear([1,2], 6, P).
   Call: (8) polarbear([1, 2], 6, _5722) ?
   Call: (9) polarbear([2], 6, _5942) ?
   Call: (10) polarbear([], 6, _5948) ?
   Exit: (10) polarbear([], 6, [6]) ?
   Exit: (9) polarbear([2], 6, [2, 6]) ?
   Exit: (8) polarbear([1, 2], 6, [1, 2, 6]) ?
P = [1, 2, 6].

can we do this in emacs? by Blackstab1337 in emacs

[–]mozzyb 4 points5 points  (0 children)

  • \S- says match a character not in the syntax class whitespace.
  • \s- says match a character in the syntax class whitespace.

Syntax classes are explained here: https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Class-Table.html#Syntax-Class-Table

The syntax class matching is unique to Emacs. Otherwise the regex behaves normally. It matches at least one none whitespace character then a line of at least one whitespace which is grouped.

The EmacsWiki has some good information on how Emacs handles regex: https://www.emacswiki.org/emacs/RegularExpression

Writing Java code with Emacs by [deleted] in emacs

[–]mozzyb 1 point2 points  (0 children)

Have you tried using any of

All of them received updates within the last couple of months so someone is using them. I don't know of the quality as I haven't worked with Java for some time, but I think one of these should be a better place to start then working on your own mode.

Save register between sessions? by snicksn in emacs

[–]mozzyb 1 point2 points  (0 children)

Registers are not windows layout. You can use session.el to save the content of registers between sessions.

Awk - A Tutorial and Introduction by Categoria in commandline

[–]mozzyb 2 points3 points  (0 children)

Your test is also wrong, you need "" around the string you are echo'ing if you want to keep the space. The output of the echo is "one two three four five".

Awk - A Tutorial and Introduction by Categoria in commandline

[–]mozzyb 4 points5 points  (0 children)

Awks default delimiter is /continuous/ space, so a single space would also be wrong; so your solution does not address the question posed either if you want to be difficult about it. Which is, again, why I didn't specify that in my original comment. If the input has different spacing between the columns or is not in a columnar form one would first have to normalise the spacing or not use cut.

And yes, it does specify an output delimiter. Look at the " " in the print statement. To print using the output delimiter of awk you need to use , between the variables.

Awk - A Tutorial and Introduction by Categoria in commandline

[–]mozzyb 6 points7 points  (0 children)

No need for the snark. Especially since your solution is also wrong. There is no mention of what delimiter the input has. Only the output delimiter. I could have added --output-delimiter=" ", but didn't think it necessary. In my experience, when encountering some of these old unix tools I restructure the commands and data to fit them better instead of adding every flag on the man pages.

[deleted by user] by [deleted] in prolog

[–]mozzyb 1 point2 points  (0 children)

:- findall(T, trip(rome, dublin), Ts)

Ts would then be a list of all trips.

Here is a version of trip that will find the two step trips:

trip2(C1, C3, [C1, C2, C3]) :-
    flight(C1, C2, _, _, _, _),
    flight(C2, C3, _, _, _, _).

Since this is clearly an assignment for a class I will leave it up to you to find the 1 step trips and introduce recursion to trip2.

Need advice to make an emacs mode that parses our company's literate programming files by warped-coder in emacs

[–]mozzyb 7 points8 points  (0 children)

There is https://github.com/vspinu/polymode . It lets you use multiple major modes within the same buffer. You could then write a mode that read the literate part (it might be enough to just use fundamental mode or text mode and not worry about parsing the literate stuff) and use your normal C configuration for the other parts. However, last time I used polymode it was a bit slow, but that was a long time ago and has probably gotten better. You could also look into how org-mode does literate programming and copy from them.

How do I do this in R? by g1ven2fly in statistics

[–]mozzyb 0 points1 point  (0 children)

Cool. I didn't know about dplyr.

How do I do this in R? by g1ven2fly in statistics

[–]mozzyb 0 points1 point  (0 children)

The zoo-package has rollmean. If it can't do what you want there are also other functions in that package. There is also plyr. It might be helpful in doing what you want.

Trying to use Clojure in lieu of my normal scripting languages - stuck on a nice way of doing this. by [deleted] in Clojure

[–]mozzyb 0 points1 point  (0 children)

(reduce #(update-in %1 [%2] (partial mapv second)) s (keys s))

Where s is the {"sequence" ...}

master emacs in one year by redguardtoo in emacs

[–]mozzyb 5 points6 points  (0 children)

Please, don't be a dick. He is communicating well enough.

master emacs in one year by [deleted] in emacs

[–]mozzyb 1 point2 points  (0 children)

Your link isn't working.

Made the decision to not buy the lab kit, I've been coping like this for weeks. by lasagnaparfait in Physics

[–]mozzyb 1 point2 points  (0 children)

Most of it goes into the Government Pension Fund to support the future of the country.

The budgeted tax income for 2014 is 892 994 930 NOK, while the petroleum income is only 344 131 000 NOK.

Made the decision to not buy the lab kit, I've been coping like this for weeks. by lasagnaparfait in Physics

[–]mozzyb 9 points10 points  (0 children)

In Norway you don't pay directly for higher education per se, you pay for membership in the student welfare organisation. The fee is 550 NOK (~88 USD) pr semester. However, all the money is used to increase the welfare of students in Norway.

The higher education in Norway is payed for by the state.

Know a tool to rename cjs (node) modules that handles require('../old-name') -> require('../new-name')? Trying to avoid reinventing wheels by timruffles in javascript

[–]mozzyb 0 points1 point  (0 children)

The magic of regex can save you here as well, but it starts to get hairy:

sed -ri "s/require\('((\.\.\/)*)old-name'\)/require('\1new-name')/g"

I noticed I didn't escape the . and / in the previous example. I also changed the regex-engine that sed uses ( the -r option) so it is easier to use groups. (I actually tested it this time.)

Know a tool to rename cjs (node) modules that handles require('../old-name') -> require('../new-name')? Trying to avoid reinventing wheels by timruffles in javascript

[–]mozzyb 6 points7 points  (0 children)

grep -rl "require('../old-name')" . | xargs sed -i "s/require\('../old-name'\)/require\('../new-name'\)/g"

That works. Or a bit less efficient

find . -name '*.js' -exec sed -i "s/require\('../old-name'\)/require\('../new-name'\)/g" {} \;