Unexpected end of input in CoffeeScript - coffeescript

I've started a little game in CoffeScript using canvas.
My problem is this error:
coffee -c -o lib/ src/
/src/interface.coffee:8:48: error: unexpected end of input
#ctx.clearRect 0, 0, #size[0], #size[1]
^
I've rewrote it many times but it still don't want to compile.
Here is the code:
class Interface:
constructor : (id) ->
#canvas = document.getElementById "#{id}"
#ctx = #canvas.getContext "2d"
#size = [#canvas.width, #canvas.height]
clear : () ->
#ctx.clearRect 0, 0, #size[0], #size[1]
Oh, and can someone tell me what exactly this error means?
Thank you in advance.

Its the colon after Interface. An easy way to debug that error for future reference:
Step 1: paste problem code into the 'Try CoffeeScript' part of the coffeescript website to repro the error.
Step 2: erase or comment-out lines until the error goes away and the code compiles
Step 3: the last line you erased was the error.
Step 4: find the error(s) in that line and fix.
Step 5: repeat as necessary.
This is how I figured out what the problem was. This process also works well for the 'Unmatched Outdent' error.

Related

Error migrating from cannon.js to cannon-es

I have a world with cannon.js physics working fine. When I try to migrate to cannon-es I get an error in the step() function:
Uncaught TypeError: bodies[i].integrate is not a function
The step() function is:
this.physicsWorld.step(1 / 60, this.experience.time.delta, 3)
And the docs for the step() function: https://pmndrs.github.io/cannon-es/docs/classes/world.html#step
I can't find anything wrong. What does that error means?
I forgot to import cannon-es instead cannonjs in one file, so I was using a mix of two libraries.

HTML2PDF : error (sometimes) when generating, but PDF generated

Let me explain !
I have a magento website. I'm generating custom PDF when my user is making an order.
It works most of the time, but for some reason, sometimes, I have this error :
Undefined property: Spipu\Html2Pdf\MyPdf::$h in ...../vendor/spipu/html2pdf/src/MyPdf.php on line 670"
The line is this :
public function getH()
{
return $this->h;
}
The class is : class MyPdf extends \TCPDF
and in TCPDF, $h is a protected variable
It's weird, knowing that my PDF is saved on my server, and I can open without getting an error..
Do you have any idea of what the problem could be ?
Ah ah got it !
Forgot to mention, i'm using a loop to make and attach my pdf to a mailer.
I had to put the declaration of the HTML2PDF inside the loop, not outside (that's make sense).
Hope this will help !

zxing : forFragment Cannot resolve symbol

How to fix this?
IntentIntegrator test = new IntentIntegrator.forFragment(this);
forFragment, forforSupportFragment too
Cannot resolve symbol
Your invocation is wrong. Should be
IntentIntegrator test = new IntentIntegrator().forFragment(this);
Notice the first parentheses.
or
IntentIntegrator test = IntentIntegrator.forFragment(this);
Sorry but I used the older version, so I am not sure how the invocation looks right now.

Spec2 :how to see failing test stacktrace and resolve "parseBody" keyword not found

I need to know two things here :
1. How to see the stacktrace of the failing test case? Right now I only see the line number it failed and the result. See the outcome of the test case below :
x return status 200
[error] '404' is not equal to '200' (LayoutControllerSpec.scala:20)
My controller uses parseBody keyword to parse json provided by JacksonJsonSupport class. how to write the test case for the action me below :
val create = post() {
var layout:Layout = parsedBody.extract[Layout] //Layout is model class
....
}
Any help or ideas would be highly appreciated.
Thanks,
PS: This code is written for scalatra framework using spec2 framework.
Let's answer the first question here.
You can use the failtrace argument to get a stacktrace for a failure
sbt> test-only *MySpec* -- failtrace
See also this question.

GetExportedValues<MyType> returns nothing, I can see the parts

I have a strange MEF problem, I tested this in a test project and it all seems to work pretty well but for some reason not working in the real project
This is the exporting code
public void RegisterComponents()
{
_registrationBuilder = new RegistrationBuilder();
_registrationBuilder
.ForTypesDerivedFrom(typeof(MyType))
.SetCreationPolicy(CreationPolicy.NonShared)
.Export();
var catalog = new AggregateCatalog();
catalog.Catalogs.Add(new AssemblyCatalog(typeof(MyType).Assembly, _registrationBuilder));
var directoryCatalog = new DirectoryCatalog(PathToMyTypeDerived, _registrationBuilder);
catalog.Catalogs.Add(directoryCatalog);
_compositionContainer = new CompositionContainer(catalog);
_compositionContainer.ComposeParts();
var exports = _compositionContainer.GetExportedValues<MyType>();
Console.WriteLine("{0} exports in AppDomain {1}", exports.Count(), AppDomain.CurrentDomain.FriendlyName);
}
exports count is 0 :( Any ideas why?
IN the log file I have many of this
System.ComponentModel.Composition Information: 6 : The ComposablePartDefinition 'SomeOthertype' was ignored because it contains no exports.
Though I would think this is ok because I wasn' interested in exporting 'someOtherType'
UPDATE: I found this link but after debuging over it I am not wiser but maybe I m not following up properly.
Thanks for any pointers
Cheers
I just had the same problem and this article helped me a lot.
It describes different reasons why a resolve can fail. One of the more important ones is that the dependency of a dependency of the type you want to resolve is not registered.
What helped me a lot was the the trace output that gets written to the Output window when you debug your application. It describes exactly the reasons why a type couldn't be resolved.
Even with this output. you might need to dig a little bit, because I only got one level deep.
Example:
I wanted to resolve type A and I got a message like this:
System.ComponentModel.Composition Warning: 1 : The ComposablePartDefinition 'Namespace.A' has been rejected. The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced multiple composition errors, with 1 root causes. The root causes are provided below. Review the CompositionException.Errors property for more detailed information.
1) No exports were found that match the constraint:
ContractName Namespace.IB
RequiredTypeIdentity Namespace.IB
Resulting in: Cannot set import 'Namespace.A..ctor (Parameter="b", ContractName="namespace.IB")' on part 'Namespace A'.
Element: Namespace.A..ctor (Parameter="b", ContractName="Namespace.IB") --> Namespace.A --> AssemblyCatalog (Assembly="assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=...")
But I clearly saw a part for Namespace.IB. So, in the debugger, I tried to resolve that one. And I got another trace output. This time it told me that my implementation of Namespace.IB couldn't be resolved because for one of its imports there was a missing export, so basically the same message as above, just with different types. And this time, I didn't find a part for that missing import. Now I knew, which type was the real problem and figure out, why no registration happened for it.