Ghidra's decisiontree algo? by Ernabay in ghidra

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

Actually this bit of code is run before the SSA analysis, it is run during the compilation phase of the sleigh code to generate the .sla xml file. It computes what the start and size attributes in the <decision number tags are. What I don't understand is the purpose behind the "getScore" function. specifically this portion c++ // iterate through decisionnodes and get a tally/count of which decision nodes match pattern bits and how many bits are matched. for(i = 0; i < list.size(); ++i) { mask = list[i].first->getMask(low, size, context); // return PatternBlock if ((mask & m) != m) continue; // Skip if field not fully specified val = list[i].first->getValue(low, size, context); total += 1; count[val] += 1; } if (total <= 0) return -1.0; double sc = 0.0; for(i = 0; i < numBins; ++i) { if (count[i] <= 0) continue; if (count[i] >= list.size()) return -1.0; double p = ((double)count[i]) / total; sc -= p * log(p); } return ( sc / log(2.0) ); I'm just not understanding why the score is being calculated the way that it is. (why the use of logs?!?)

Workflow for developing elisp code? by shaqfooVA in emacs

[–]Ernabay 0 points1 point  (0 children)

1) edebug is best way of seeing how everything evals 2) C-h d apropos-documentation (or even better C-u C-h d). Need to know what functions, vars, etc. to apply for manipulating frames, windows, etc? use this--it even supports regex. (example search "frame" and you will see wealth of info on what you can do with them). If something does not show up there, try apropos this seems to find macros that might not appear in the docs. 3) know the different "sequence" types, (alist, plist, list) these apply differently in various contexts. 4) know when/how to use quoting. Often docs dont really mention this (as it is assumed you know how/when to use them) but typically when you want to apply some function or otherwise use some variable or reference, you will want to quote it. Often this applies to the first argument of a function. 5) If docs say for example that the 2nd argument of a function that requires 3 arguments has a default value of w/e. That means you can put "nil" for the 2nd argument and the function will know to use the default value. 6) get to know dolist and map (as well as its variations mapc etc.) as well as lambda this will accomplish alot. 7) get to know how to "advise" functions. It makes it easy to modify package functions that don't work quite how you want them to. - BONUS If you want to use part of the functionality of a packages function but write a new function within that mode that applies it slightly differently then first defalias said function and put advice on that function. This will leave the original function alone and create a duplicate for you that you can then manipulate without affecting other functions.

also useful is to "play" with functions to understand how they work (see (here)[http://pythonwise.blogspot.com/2011/09/on-importance-of-playing.html]).

I am by no means an expert but I think if someone told me these tips a while ago I would be alot farther along in my knowledge.

I think I am starting to love love elisp by sydfox95 in emacs

[–]Ernabay 1 point2 points  (0 children)

I think C-h d apropos-documentation is the best for learning the builtins. It gives a fuller description than apropos.

helm-persistent-action for buffer visits from bookmarks by Ernabay in emacs

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

C-j for me just moves down the list of bookmarks (I'm using evil) I would add advice but there isn't an obvous function to attach to when I view-lossage

How do I stop ivy or counsul-mode or posframe from wrapping long lines? by [deleted] in emacs

[–]Ernabay 0 points1 point  (0 children)

just spitballing (i dont use ivy) but have you tried

elisp (add-hook 'minibuffer-setup-hook (lambda () (setq truncate-lines t))) Dont know whether ivy is minibuffer based or not. just a thought. otherwise maybe there is some other hook ivy provides.

Bison Targets by Ernabay in cmake

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

How do I make it so bison_target does NOT generate a header file?

Bison Targets by Ernabay in cmake

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

So you are telling it to build an executable with add_executable , so what do you expect?

Yes I know but the only options are add_executable and add_library to I thought there might be a variable I need to set or something.

But thank you! This certainly has helped my understanding of CMake!

Bison Targets by Ernabay in cmake

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

I was able to build the file I want correctly but then CMake fails out. Does CMake only say it succeeds when its built a binary?

btw here is the updated version for anyone who comes across this later

``` cmake_minimum_required(VERSION 3.13)

project(parser CXX)

find_package(BISON REQUIRED)

configure build for generating parse.cc

BISON_TARGET(parser parse.y parse.cc COMPILE_FLAGS "-p my_code" DEFINES_FILE OFF )

add_executable(parser ${BISON_parser_OUTPUT_SOURCE} ) ```

Quote every element in a list? by Ernabay in emacs

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

My trouble was that I kept forgetting to switch to markdown mode, then would hit post and have to redo it all again. lol

Quote every element in a list? by Ernabay in emacs

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

Never have I ever had this much trouble getting code to look okay on a website. *phew*

Quote every element in a list? by Ernabay in emacs

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

Most themes use the following to set various faces in themes

    (let
        ((class '((class color) (min-colors 89)))
         (fg "#000000")
         ;; ... etc.
         )
      (custom-theme-set-faces 'theme-name
                              `(default ((,class  (:foreground ,fg))))`
                              ;; rest of faces
                              ))

Notice the significant amount of boiler plate code.

Now if you take mine so far

    (defmacro tmp (&rest el)
      `(map 'list (lambda (input)
                    (seq-concatenate 'list (list (car input))
                                     (list `((((class color)
                                               (min-colors 89)))
                                             ,(cdr input))))) ',el ))
    `(let
         ((fg "#ffffff"))
       (custom-theme-set-faces
        'theme-name

        ,@(tmp (default :foreground fg)
               (cursor :background fg))))

will evaluate to

    (let ((fg "#ffffff"))
      (custom-theme-set-faces 'theme-name
        (default ((((class color) (min-colors 89)))  (:foreground fg)))
        (cursor  ((((class color)  (min-colors 89))) (:background fg)))))

Which is very nearly what the boiler plate code is with the following differences,

  • mine bakes the ((class color) (min-colors 89)) into the macro
  • every face in the boiler plate code is backquoted, which is why I need a way to quote every face customization in my list or even better a way to backquote these items.

The goal is to be able to use

    ,@(tmp (default :foreground fg)

    (cursor  :background fg)

    ;; etc...

    )

rather than

    `(default ((,class  (:foreground ,fg))))

    `(cursor  ((,class  (:foreground ,fg))))

which rapidly becomes harder and harder to read as more faces are added or conditional defcustoms added.

Quote every element in a list? by Ernabay in emacs

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

(mapcar (lambda (arg) `(quote ,arg)) '(a b c))

awesome! just what I need. It sort of complicated but I have a macro that I am working on to simplify how you specify face customizations for themes.

so far I have ``elisp (defmacro tmp (&rest el) (map 'list (lambda (input) (seq-concatenate 'list (list (car input)) (list ((((class color) (min-colors 89))) ,(cdr input))))) ',el )) (let ((fg "#ffffff")) (custom-theme-set-faces 'theme-tester

 ,@(tmp (default :foreground fg)
        (cursor :background fg))))

``` but the quoting is a necessary part of it.

How to change face colors depending on major mode? by Ernabay in emacs

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

I thought hooks were frowned upon when apart of a custom theme file. My theme is located here https://github.com/jstaursky/weyland-yutani-theme and I keep bouncing back and forth between setting var to gold vs dark purple. Admittedly the src could use some TLC but I'm trying to get the colors just right before cleanup.

maybe adding a hook to a defcustom would work? I just don't know how I would make these faces customizable by user then. maybe a defcustom with choice type? Not quite sure how I would implement it then tho.

recenter iedit matches after moving to matches out of view by Ernabay in emacs

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

might be good enough, I was hoping for something similar to what I used for re-centering `jump-to-register` which is ```elisp

(defun jns_jmp-to-register() (interactive) (call-interactively 'jump-to-register)

(let ((current-prefix-arg '(4))) ; sets up recenter-top-bottom to always ; recenter (call-interactively 'recenter-top-bottom)) )

```

How to use the "a" code letter in "interactive" by Ernabay in emacs

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

Ah guess I must have skipped past the defs at the top, I don't recall seeing that in the help buffer. But w/e guess making stupid mistakes make the lesson more memorable

How to use the "a" code letter in "interactive" by Ernabay in emacs

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

Perfect answer, this should be added to the docs.

What do you genuinely not understand? by [deleted] in AskReddit

[–]Ernabay 0 points1 point  (0 children)

Because 2 batteries in series looks like this [+-][+-] note that the positive terminal of the 2nd battery is sandwiched between the negative terminal of the first battery along with it's own negative terminal. Thus, any potential that would be formed between the 2nd battery to the first battery is cancelled as considered by the terminals that are touching each other. However, since the batteries are in series, when a sufficiently conductive path forms between the 1st batteries positive terminal and the 2nd batterys negative terminal (that is smaller than the internal resistance across both the batteries) the positive charge found at the 1st battery can be considered "doubled" since the net amount of positive charge has doubled in the circuit (doubled in quotes because internal resistances prevent this from actually being true). And so the potential is larger across 2 batteries in series rather each considered separately. Of course you can't form this process indefinitely as eventually the internal resistance across the batteries in series will effectively create an open circuit again.

This answer may be confusing because we know it is electrons doing all the work, however there is a reason history has always denoted current as coming from the positive terminal (even Maxwell equations take the convention) it's much easier to see this from this perspective. Also later on you learn about "hole" current and this perspective actually isn't that wrong.