coffeescript

Getting “Symbol Lookup Error” when calling C library from C++ (Node.js Addon)

纵饮孤独 提交于 2019-12-23 12:46:20
问题 I am working on a Node.js addon that needs to wrap the objects from a C library in C++ so they can be accessed from client-side JavaScript (written in CoffeeScript). The C++ module compiles, but when I try to run it through Node.js JavaScript, the C library fails to be called with a symbol lookup error that I'm having problems debugging. The error is below: node: symbol lookup error: /var/lib/cloud9/ledscape-wrapper/wrapper/build/Release/wrapper.node: undefined symbol: ledscape_init wrapper

Mongoose right promise rejection handling

倾然丶 夕夏残阳落幕 提交于 2019-12-23 12:14:25
问题 I'm bit fighting with promise pattern in nodeJS I'm looking for user in db and then saving new entity with user reference, but when user is not in db, I should return rejection, but I'm not sure how to do it properly. is there way how to do it more nicely? btw: sorry, coffeescript :-[ User.findOne({'fbId':userData.me.id}).exec().then((doc)-> if !doc? then return new Promise (resolve,reject)->reject(404) video = new Video({ user:doc state: "queue" createdAt: new Date() }) video.save().exec() )

How to set params when subscribing to Action Cable channel

拟墨画扇 提交于 2019-12-23 09:47:51
问题 I've been trying to get my head around action cable for what seems like months. Please help. I have a "Connection" - I can't set the identified_by :current_user because this endpoint also needs to be consumed by an external API that uses WebSockets. Can't use browser cookies to authenticate the API endpoint. Files & Support Connection: /app/channels/application_cable/connection.rb module ApplicationCable class Connection < ActionCable::Connection::Base end end Channel: /app/channels

jQuery element.closest(…).attr is not a function when using each

筅森魡賤 提交于 2019-12-23 09:41:25
问题 When iterating over some DOM elements I found it impossible to use .data or .attr on them: $('.running').each (index, element) => console.log element.closest('[data-id]') gets me <section class="job-block" data-id="240"></section> ... but $('.running').each (index, element) => console.log element.closest('[data-id]').data('id') throws Uncaught TypeError: element.closest(...).data is not a function 回答1: The closest() method that you are using is native JS method and which returns DOM element

400 Bad Request when attempting to insert QR code image for Google Authenticator

烈酒焚心 提交于 2019-12-23 09:18:14
问题 I'm trying to set up two-factor authentication with Google Authenticator on my site. I'm able to generate working codes, but when I insert the image URL into the page, I get the following error in Chrome inspector: GET https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/MyLabel?secret=THESECRET 400 (Bad Request) The code to generate the QR code: try key = crypto.randomBytes(10).toString('hex') catch error console.log "error generating code: #{error}" encoded = base32

Can I use Coffeescript in client side too?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 09:16:18
问题 Is there any way to use CoffeeScript in client side? 回答1: There are two ways: Compile the CoffeeScript to JavaScript and deploy it as you would any JavaScript file, or Use coffee-script.js , which allows you to put <script type="text/coffeescript> tags in your page. The latter isn't recommended for production use, but it's nice for development. See the related question: Is there a way to send CoffeeScript to the client's browser and have it compiled to JavaScript *there*? 回答2: See also

Returning HTML to AJAX Rails calls

≯℡__Kan透↙ 提交于 2019-12-23 09:10:05
问题 After reading David Heinemeier Hansson's blog post about server-generated javascript I decided to review the way I approach making AJAX calls in my Rails applications. What David suggests is to create a .js.erb template, which is just javascript embedded with ruby code generated on the server, and not to do any DOM manipulation in the client-side javascript. Another approach is of course to simply do everything on the client-side, and (for example) return a JSON object representing the

coffeescript Class not accessible in main javascript

半腔热情 提交于 2019-12-23 07:45:29
问题 I have a class written in coffeescript, e.g., class Example constructor: -> $.each [1, 2, 3], (key, value) => @test = value return @test render: -> alert @test and I have this class as a separate file, Example.coffee Now I want to be able to instantiate in my main javascript file like so: d = new Example d.render() but the class is undefined even when it is included as a script on the page, like <script src="Example.js></script> <script src="main.js"></script> How do you make the class

angular.injector(..).invoke in the console not returning a singleton

ε祈祈猫儿з 提交于 2019-12-23 05:20:17
问题 The script: app = angular.module('app', []) app.factory 'MyFactory', -> val: 'Clark Kent' app.controller 'MainCtrl', ($scope, MyFactory) -> MyFactory.val = 'Waldo' $scope.myFactory = MyFactory Put this in the console: angular.injector(['ng','app']).invoke(function(MyFactory) { console.log(MyFactory); }) ... and instead of Waldo , you get Clark Kent !! Why doesn't it return the same object? Check out the plunkr 回答1: Services in Angular are singletons in the sense that they are only created

Update Stripe Credit Card with Coffeescript

时光毁灭记忆、已成空白 提交于 2019-12-23 03:45:50
问题 I finally figured out how to implement Stripes Monthly Billing using this tutorial Currently my Submit Button for both my #new_subscription form and edit form creates and sends credit card data to Stripe. But for some reason I keep getting this error when I update the Credit Card can't convert Symbol into String app/controllers/subscriptions_controller.rb:38:in `update' Question: Is this error due to the coffeescript, or is my update_card method in my model causing this problem? EDIT FORM <%=