coffeescript

connect EADDRNOTAVAIL in nodejs under high load - how to faster free or reuse TCP ports?

一世执手 提交于 2019-12-22 08:05:35
问题 I have a small wiki-like web application based on the express-framework which uses elastic search as it's back-end. For each request it basically only goes to the elastic search DB, retrieves the object and returns it rendered with by the handlebars template engine. The communication with elastic search is over HTTP This works great as long as I have only one node-js instance running. After I updated my code to use the cluster (as described in the nodejs-documentation I started to encounter

What is wrong with my coffeescript in Stripe?

拟墨画扇 提交于 2019-12-22 06:59:26
问题 I've been working on integrating Stripe into my web application, and it doesn't seem to be working. To help me along, I've been using Ryan Bates's Rails Cast on integrating Stripe. Whenever I try to run the payment form, I get an error saying that "There was a problem with my credit card". I think the problem lies in my coffeescript file, but perhaps I'm wrong. I've included the stripe user token as a part of my user model instead of placing it into its own subscription model. Here is the

How can Coffescript access functions from other assets?

我与影子孤独终老i 提交于 2019-12-22 06:44:57
问题 So I have two controllers, hotels and videos . I want the hotels.js.coffee to be able to access functions created in videos.js.coffee but I get a "is not defined" error. I'm new to CoffeeScript so any clues would be appreciated. 回答1: CoffeeScript will compile your coffee to JS wrapped in a self-executing function with the scope of the window (function{}).call(this); So in videos.js.coffee you can write something like: @getVideo: (id) -> and the getVideo function will be bound to the window

Bootstrapping a Backbone application

。_饼干妹妹 提交于 2019-12-22 06:42:54
问题 I have seen a couple of ways on how to do this, but I can never figure out which is the 'correct' way. Jeffrey Way from NetTuts+ and Addy Osmani instantiate a 'main' application view in order to kick off their applications. require(['views/app'], function(AppView) { new AppView(); }); Ryan Bates from Railscasts starts his application by instantiating a router which then handles subsequent requests: window.App = Models: {} Collections: {} Views: {} Routers: {} init: -> new App.Router()

Could not find coffee-script-source-1.1.3 in any of the sources

北慕城南 提交于 2019-12-22 06:39:14
问题 Hi I'm doing Rails app and when I bundle install it returns an error: Could not find coffee-script-source-1.1.3 in any of the sources I know that coffee-script-source-1.1.3 gem is deprecated/yanked but my other gems are having dependencies with this. But this project is working with other machine and in heroku production. How can I successfully bundle install this without changing my gemfile? Thanks 回答1: Run this: bundle update --source coffee-script-source If you get an error, like this: An

PhantomJS unexpected load behavior with multiple pages

限于喜欢 提交于 2019-12-22 06:23:24
问题 i have a script (below) that scrapes a site with a 3 step process. it works great when set to a maximum of 1 page at a time. however, when i increase that to 2 at a time things start getting wonky. the onFinished fires earlier than i would expect and the page isn't completely loaded yet. because of this the rest of my script breaks. any idea why this might be happening? i should add that i'm using the newest version (1.5). MAX_PAGES = 1 ### changing MAX_PAGES to >1 causes some pages

AngularJS $http.get returns undefined and $http() is not a function

爷,独闯天下 提交于 2019-12-22 04:38:21
问题 I'm building an app to dynamically load and display data from a database in AngularJS, but when I try to access my API (using either $http() or $http.get()), I receive errrors. $http.get() error: TypeError: undefined is not a function , $http() error: TypeError: object is not a function This specific error occurs in the code to dynamically load navigation tabs. The code for both in CoffeeScript: p4pControllers.controller 'navCtrl', [ '$routeParams' '$scope' '$http' ($http,$scope,$routeParams)

CoffeeScript: coffee -w name-of-file.coffee complains: “window is not defined”

拈花ヽ惹草 提交于 2019-12-22 04:11:51
问题 In CofeeScript I am creating a global object by doing this: window.App = init : -> ... Running coffee -w app.coffee complains window is not defined and doesn't rewrite the app.js file. However, running coffee -c app.coffee compiles without a problem. How can I get coffee -w to accept global window ? CoffeeScript version is 1.1.1 (from coffee -v ) Thanks! 回答1: If you want to watch a file and have it compiled you need to do: coffee -wc file.coffee Using only the -w flag causes coffee to just

CoffeeScript String Comparison

限于喜欢 提交于 2019-12-22 03:28:50
问题 In CoffeeScript, is there a way to simplify the following: if(value === "something" || value === "else" || value === "wow"){} I've tried: if value is "something" or "else" or "wow" But this produces the literal output of this: if(value === "something" || "else" || "wow){} Is there a way to check if a string is one of multiple values (OR or AND) in CoffeeScript? 回答1: I think you probably want if value in ['something', 'else', 'wow'] 来源: https://stackoverflow.com/questions/15508037/coffeescript

Get next key-value pair in an object

自作多情 提交于 2019-12-22 01:26:35
问题 Given a key, I want to find the next property in an object. I can not rely on the keys to be ordered or sequential (they're uuids). Please see below for trivial example of what I want: var db = { a: 1, b: 2, c: 3 } var next = function(db, key) { // ??? } next(db, 'a'); // I want 2 next(db, 'b'); // I want 3 I also want a prev() function, but I'm sure it will be the same solution. This seems like such a trivial problem but I can't for the life of me figure out how to do it. Happy for the