How do I have the javascript generated by coffeescript?
I am having an issue where I have a basic command that blows up with Error:
msg is not defined
module.exports = (robot) ->
robot.respond /(\S+) ref (\S+)/i, (msg) ->
msg.send "Calculating..."
project = msg.match[1]
dll = msg.match[2]
exec = require('child_process').exec
msg.send "variables #{project} and #{dll}"
msg.send "x"
Just depending on magic I could erase most of the code in robot.respond -> except 3 messages and sometimes the last one will fail. I have a feeling some kind of funky white space thing is going on here. I am using SublimeText editor which should not put garbage characters into my code.
This code uses Hubot, but I don't think that matters.
coffee -c filename.coffee produces filename.js. In my case, the generated file prevented coffeescript from making any further updates to filename.js. So as I changed my filename.coffee file it looked like nothing worked, when in fact the code simply was not changing. I deleted filename.js and the code began working again.
Related
I am using Play 2.6 and for the first time am having issue inserting another template into another one.
Here's my structure:
And here's the template projectView I'm currently working on:
#import views.html.afterLogin.projectWorkspace._
#import views.html.afterLogin.dashboard
#(projectName: String, userName: String)
#main(s"Track Wild: $projectName") {
#loggedInNavbar("projects", userName)
#dasboard("name")
#projectToolbar
#success
<h1>Stuff</h1>
}
IntelliJ is telling me it cannot resolve:
#dasboard("name")
#projectToolbar
and the html in #import views.html.afterLogin.dashboard
It's also saying the import statements are both unused. However, I can link just fine to some of the other templates in other packages higher up in the chain. I can't figure out why it's allowing some and not others...
I have no idea why, but it was something with IntelliJ:
I clicked File -> Invalid Caches/Restart
Before I did that, I had also gone into my project structure and:
target-> scala-2.12. -> twirl
ctrl + click: Mark Directory as: unexcluded
I don't know if this did anything though. Try invalidating the cache and let IntelliJ do a full restart (let it finish indexing everything) first. If that doesn't do it, then try unexcluding the twirl directory, THEN invalidating the caches and restarting.
It looks to me that the line with #dasboard("name") might contain a typo in "dashboard", see if that helps in solving the issue any further.
I'm trying to write a init script for the Atom editor to add a custom command to be able to reveal the currently opened editor file in the tree-view with one key combination, instead of two.
Here is an example code (which makes something different) to make clear how it generally has to look like.
atom.commands.add 'atom-editor', 'custom:cut-line', ->
editor = atom.workspace.getActiveEditor()
editor.selectLine()
editor.cutSelectedText()
The two commands I need should not be sent to the editor, but to the tree-view. Here are the two commands:
tree-view:toggle-focus
tree-view:reveal-active-file
I assume I have to do something similar as above, like getActiveTreeView or something like that. I tried to google it but it doesn't seem to be obvious. Does someone know how to do this?
It could look something like this:
atom.commands.add 'atom-editor', 'custom:show-active-file', ->
tree-view.toggle-focus()
tree-view.reveal-active-file()
You can use the atom.commands.dispatch() method to send a command when getting a hold of the object to send the commands to is hard. In your case, you can use:
atom.commands.add 'atom-editor', 'custom:show-active-file', ->
atom.commands.dispatch(atom.workspaceView.element, 'tree-view:toggle-focus')
atom.commands.dispatch(atom.workspaceView.element, 'tree-view:reveal-active-file')
Sadly, Lee's answer is not correct anymore. Within changes in the API the changed the naming of atom.workspaceView to atom.workspace.
So, if anyone gets here (sure questions and answer is a "bit" old), here's the current working script.
atom.commands.add 'atom-editor', 'custom:show-active-file', ->
atom.commands.dispatch(atom.workspace.element, 'tree-view:toggle-focus')
atom.commands.dispatch(atom.workspace.element, 'tree-view:reveal-active-file')
#Source
https://discuss.atom.io/t/workspaceview-events/14595/4
Apologies for the lack of precision in the question, but I'm not completely sure which of possibly many things I'm doing wrong here.
I'm relatively new to Coffeescript and also geo applications in general, but here goes:
I've got a working (simple) Meteor (.7.0.1) application utilizing coffeescript in both client and server. The issue I'm having occurs when attempting to utilize TopoJSON encoded files to create a layer of US congressional districts. (the purpose of the app is to help highlight voter suppression in the US)
So, a few things: Typically in a non-Meteor app, I would just load the topoJSON file like so:
$.getJSON('./data/us-congress-113.json', function (data) {
var congress_geojson = topojson.feature(data, data.objects.districts);
congress_layer.addData(congress_geojson);
});
Now of course this won't work in Meteor because its not asynchronous.
One of the things that was recommended here on SO was to not worry about reading the file, and to instead change the json file to .js, and then set the contents (which are of course just an object) equal to a variable.
Here's what I did:
First, I changed the .json file to a .js file in the server directory, and added the "congress =" to the beginning of the file. It's a huge file so forgive me for omitting the whole object.
congress = {"type":"Topology",
"objects":
{"districts":
{"type":"GeometryCollection","geometries":[{"type":"Polygon"
Now here's where everything starts to give me issues:
In the server.coffee, I've created a variable like so to reference the congress object:
#congress_geojson = topojson.feature(congress, congress.objects.districts)
Notice how I'm putting the # symbol there? I've been told this allows a variable in Coffeescript to be globally scoped? I tried to also use a Meteor feature called "share" where I declare the variable as "share.congress_geojson". That led to the same issues which I will describe below.
Now in the client.coffee file, I'm trying to call this variable to load into a Leaflet map.
congress_layer = L.geoJson(null,
style:
color: "#DE0404"
weight: 2
opacity: 0.4
fillOpacity: 0.1
)
congress_layer.addData(#congress_geojson)
This isn't working, and specifically (despite attempts to find other ways, the errors I'm getting in the console are:
Exception from Deps afterFlush function: TypeError: Cannot read property 'features' of undefined
at o.GeoJSON.o.FeatureGroup.extend.addData (http://localhost:3000/packages/leaflet.js?ad7b569067d1f68c7403ea1c89a172b4cfd68d85:39:16471)
at Object.Template.map.rendered (http://localhost:3000/client/client.coffee.js?37b1cdc5945f3407f2726a5719e1459f44d1db2d:213:18)
I have no doubt that I'm missing something stupidly obvious here. Any suggestions or tips for what I'm doing completely wrong would be appreciated. Is it a case where an object globally declared in a .js file isn't available to code in a .coffee file? Maybe I'm doing something wrong on the Meteor side?
Thanks!
Edit:
So I was able to get things working by putting the .js file containing the congress object in a root /lib folder, causing the object to load first, and then calling the congress object from the client. However, I'm still wanting to know how I could simply share this object from the server? What is the "Meteor way" here?
If you are looking for the Meteor way to order the loading of files, use the Meteor.startup function and put the initialization code there. That function is the $.ready of the Meteor world, i.e., it will execute only after all your files have been successfully loaded on the client.
So in your case:
Meter.startup ->
congress_layer.addData(#congress_geojson)
In OSX 10.6 I used the following code to do something to each currently selected file in Finder:
app('Finder').selection.get.each do |item|
url =CGI::unescape(item.URL.get)
puts url
do_pdf(url[16..-1])
end
(this is launched by Keyboard Maestro). This worked perfectly fine, however in OSX Lion, the behaviour seems to have changed.
selection.get still returns the right reference
app('Finder').selection.get[0]
=> app"/System/Library/CoreServices/Finder.app"disks["Home"]folders["stian"]folders["Downloads"]document_files["Comprehensive Examination (1).doc"]
however, when I try to extract it with URL.get, I get a weird number:
app('Finder').selection.get[0].URL.get
=> "file:///.file/id=6637683.2924283"
How do I take the reference above and get a POSIX path as a text string (/Home/stian/Downloads/Comprehensive Examination (1).doc)?
I can get a text version of the entire reference like this:
app('Finder').selection.get[0].get.to_s
=> "app("/System/Library/CoreServices/Finder.app").disks["Home"].folders["stian"].folders["Downloads"].document_files["Comprehensive Examination (1).doc"]"
so I guess I could parse this manually and construct the POSIX path, but that seems very cumbersome and brittle.
Thanks for any help!
In Python, it's
app('Finder').selection.get(resulttype=k.alias)[0].path
I guess in Ruby it would be
app('Finder').selection.get(:result_type=>:alias)[0].path
I have a call to an XMLRPC implemented in Java which I have verified that runs without exceptions and writes the output. The call in Perl goes like this:
my $result = XMLRPC::Lite
-> proxy($url)
-> call("someMethod",
SOAP::Data->type(string => $par1),
SOAP::Data->type(string => $par2),
# etc...
)
-> result;
But then I check for $result and it is not defined, I get Bad file descriptor error.
What could be happening? It was working before, I can't think of anything significant that may have changed...
OK, I found it, although I don't quite understand why it happened.
The XMLRPC app does this:
byte[] result = xServer.execute(request.getInputStream());
getLogger().log(new String(result));
response.setContentType("text/xml");
response.setContentLength(result.length);
OutputStream out = response.getOutputStream();
out.write(result);
out.flush();
getLogger().log("finished doPost");
I'm logging the result that is sent to the output and therefore I should be getting it in the Perl script's $result variable. The result is XML generated via the Jdom library.
While I got the error, what got logged was an XML cointaining an error message indicating a problem with Jdom (basically, the app wasn't fully recompiled to that version of the library).
Now that it works, the expected XML is logged and successfully assigned to $result in Perl.
However, since the byte array is an XML in both cases I don't quite understand how it makes any difference to the caller. It wasn't even looking for a given XML sctructure, the call resulted in an error.
Any insight on this will be appreciated. However the problem is solved.