clojurescript breakpoints - clojure

Is there any way to create breakpoints in clojurescript?
Either in the repl or in chromes native debugger.
I've tried (js* "debugger") and this returns
SyntaxError: Unexpected token debugger
Thanks!

(js* "debugger;") should work. You're just missing the semicolon.

In case someone see this later,
If you are inside a go block you might need to use this: (js* "0; debugger") because go macros creates variables definitions everywhere, so that fix on that scenario.
If for some other reason it doesn't, check the error log, you must like can find a way to "hack" the invalid compilation by adding something.

Related

SwiftUI NavigationLink Error: Unnamed argument #2 must precede argument 'destination'

How do I fix this? The recommended fix just causes more problems. I have code in another project where this exact same scenario works but when I'm applying it to this project I get an error I've never seen before. Am I missing something? Thanks
Figured it out it had something to do with the function buttonhit. Once I fixed it, it works now
Write the Image and both Text in VStack in the Navigation Link.

Suppress F# Compiler Warning: Possible incorrect indentation: this token is offside of context

I have some xunit tests I would like to layout as follows for readability:
[<Fact>] let ``Has Hash Code 2``() = target.GetHashCode().ShouldBe 2
[<Fact>] let ``ToString yields two``() = target.ToString().ShouldBe "two"
[<Fact>] let ``Has underlysing type int``() = target.GetUnderlyingType().ShouldBe typeof<int>
I'm getting a compiler warning on the let statements: "Possible incorrect indentation: this token is offside of context started at position %s. Try indenting this token further or using standard formatting conventions."
I tried #nowarn "lexfltTokenIsOffsideOfContextStartedEarlier" but that just generated another compiler warning "Invalid warning number".
There isn't a warning number listed for this error in https://github.com/fsharp/fsharp/blob/057dbf77df7355321c3c18137c2d552bdfa1272b/src/fsharp/FSComp.txt
Is there a way to suppress this warning?
I apologize for answering in a style, "you don't need it", but this seems to be the case. Also, this question apparently becomes a FAQ for those who write Unit Tests in F#. Yet another case is for [<Literal>]'s.
Anyway, disabling warnings on a project- or even file-level seems to be a bad idea, unless you have a good reason to do that.
As far as I understood, you'd like to have the statements to be one-liners (e.g., [<Fact>] did not occupy an entire line). There are two ways to accomplish that in VS2013:
Place the attribute inside let:
let [<Fact>] ``Has Hash Code 2``() = target.GetHashCode().ShouldBe 2
Write a double-semicolon after the declaration:
[<Fact>] let ``Has Hash Code 2``() = target.GetHashCode().ShouldBe 2;;
Try this:
#nowarn "0058"
To find out what the correct warning number is, just build the thing in command line (or in VS and then go to View -> Output -> Build), it will tell you. Here is what I see:
Program.fs(7,3): warning FS0058: Possible incorrect indentation: this token is offside of context started at position (5:25). Try indenting this token further or using standard formatting conventions.

Mongoid 4 finding embedded documents by ID

I have a project that is my first serious dive into Mongoid.
I saw a tip to use the following command:
Parent.where('childrens._id' => Moped::BSON::ObjectId(params[:id])).first
But this doesn't work. Error message was:
NameError: uninitialized constant Moped::BSON
I found that BSON is no longer included, so I added it to my Gemfile, as well as Moped. Then, I did another fix I found (placing Moped::BSON=BSON in application.rb).
This still didn't work, but the error changed to:
NoMethodError: undefined method `ObjectId' for BSON:Module
So I am assuming that this method got deprecated or something. Does anyone have any other tips?
Just to be clear, I am finding myself in the situation where I want to sort embedded documents using jquery-sortable. This requires me to update them in the database, but the serialize from that doesn't include the parent document in the hash. So I figured I'd try to get it on the back end using an ID from the embedded document. That is why I need it.
Thanks again for any help you can provide.
Try simply:
Parent.where('childrens._id' => params[:id]).first
I have solved the question though this won't be of much help to people in the future. The requirements have changed and now I am using human-readable strings as IDs to assist in friendly URLs and some other stuff.
Therefore, I don't have any issues with ObjectIds. Cortex's solution should (from what I have read) work for dealing with ObjectIds but I cannot verify it now.

onSessionEnd apparently not firing

I have an INSERT INTO Logfile in onSessionStart, and an UPDATE in onSessionEnd.
I've test it manually by calling onSessionEnd from elsewhere within the Application.cfc, so I know that it is working.
But that's the only time it's ever fired.
I wonder if onSessionEnd is never being fired.
I got enough upvotes on my comment, I figured I'd make it an answer for how to debug onSessionEnd methods.
First off, you need to remember that if you call onSessionEnd directly, it's being called during a regular request context. This means it has access to variables that it won't normally have access to if it's being called during the regular session end. This means that testing "manually by calling onSessionEnd" isn't a valid way to test the method.
To that end, the only way to reliably debug an onSessionEnd method is with judicious use of the cflog tag. You need to add cflog entries to flag when the method runs, you need to have error catching, to log errors or dump out cfcatch scopes to a file for review. You also need to make sure that anything you're referencing in the method is passed in via the SessionScope and ApplicationScope arguments, and that you're not referencing any scopes other than Arguments and Server. See livedocs for reference.
Hopefully that helps you find the source of your issue.
I'd add that you even can't call other Application.cfc functions from within onSessionEnd method.

attributes.someParam cannot be evaluated in coldfusion

I have in my cfm something like this
<CFModule name="MyModule"
someParam_one="#something.one#"
someParam_two="#something.two#"
someParam_etc="etc_etc_etc"/>
And inside my module, I have an
<CFSet param_name = "someParam_one">
...
evaluate("attributes." & param_name)
On most of our servers, this work. But on one of our servers, I get a
Error resolving parameter ATTRIBUTES.SOMEPARAM_NAME
Any ideas why?
Thanks
Have you verified that someParam_one is actually getting created? I've found, for example, that if I do something like this:
<cfset foo = myObject.getSomething() />
and getSomething returns a void value or runs a Java function that doesn't return anything, that CF will choke on it. The variable will be "defined", or so the application seems to think, but attempting to access it will throw an error. So do the following to track down and catch the problem:
Dump your attributes scope to make sure that what you want is indeed actually there.
Run a StructKeyExists(Attributes, param_name) before attempting to access the variable.
Get rid of the evaluate, and instead use Attributes[param_name]
Tangential to your question, but Evaluate() is evil, and an unnecessary evil in this situation. You can write this instead, and it will be more clear, more secure, and faster:
<cfset param_name = "someParam_one">
...
<cfset param_value = Attributes[param_name]>
A shot in the dark:
There's a bug in CFMX where if you
make a CFMODULE call to a template (or
use custom tag) from within a CFC and
that tempate uses the CALLER scope to
return data, the data is never
available to the CFC function. This is
bug 51067 and it is related to the
VARIABLES scope bug, 45138.
Seen in the user comments in the CFMX 6 docs on CFMODULE.
Ok, we did something really stupid :-)
We had two set of these files deployed and one was updated while the other was not, thus the error.
Thanks for all your help.