Search Results

Search found 7781 results on 312 pages for 'd3 js'.

Page 13/312 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • NodeJS and node-mongodb-native

    - by w1nk
    Just getting started with node, and trying to get the mongo driver to work. I've got my connection set up, and oddly I can insert things just fine, however calling find on a collection produces craziness. var db = new mongo.Db('things', new mongo.Server('192.168.2.6',mongo.Connection.DEFAULT_PORT, {}), {}); db.open(function(err, db) { db.collection('things', function(err, collection) { // collection.insert(row); collection.find({}, null, function(err, cursor) { cursor.each(function(err, doc) { sys.puts(sys.inspect(doc,true)); }); }); }); }); If I uncomment the insert and comment out the find, it works a treat. The inverse unfortunately doesn't hold, I receive this error: collection.find({}, null, function(err, cursor) { ^ TypeError: Cannot call method 'find' of null I'm sure I'm doing something silly, but for the life of me I can't find it...

    Read the article

  • custom helpers inside each block

    - by Unspecified
    myArray = [{name: "name1", age: 20}, {name: "name2", age:22}]; {{#each person in myArray}} {{#myHelper person}} Do something {{/myHelper}} {{/each}} Handlebars.registerHelper(function(context, options){ if(context.age > 18){ return options.fn(this); }else{ return options.inverse(this); } }) In the above code when I tried to debug my custom helper it shows the context="person" while I want the context to be the person object, what's wrong with my code ? I found a similar question here but did not get it either...

    Read the article

  • Backbone: Easiest way to maintain reference to 'this' for a Model inside callbacks

    - by Garrett
    var JavascriptHelper = Backbone.Model.extend("JavascriptHelper", {}, // never initialized as an instance { myFn: function() { $('.selector').live('click', function() { this.anotherFn(); // FAIL! }); }, anotherFn: function() { alert('This is never called from myFn()'); } } ); The usual _.bindAll(this, ...) approach won't work here because I am never initializing this model as an instance. Any ideas? Thanks.

    Read the article

  • What are the differences between these three patterns of "class" definitions in JavaScript?

    - by user1889765
    Are there any important/subtle/significant differences under the hood when choosing to use one of these three patterns over the others? And, are there any differences between the three when "instantiated" via Object.create() vs the new operator? The pattern that CoffeeScript uses when translating "class" definitions: Animal = (function() { function Animal(name) { this.name = name; } Animal.prototype.move = function(meters) { return alert(this.name + (" moved " + meters + "m.")); }; return Animal; })(); and The pattern that Knockout seems to promote: var DifferentAnimal = function(name){ var self = this; self.name = name; self.move = function(meters){ return alert(this.name + (" moved " + meters + "m.")); }; return {name:self.name, move:self.move}; } and The pattern that Backbone promotes: var OneMoreAnimal= ClassThatAlreadyExists.extend({ name:'', move:function(){} });

    Read the article

  • Unable to call views

    - by Scott
    I'm using Sails and I when I attempt to call the login action of my UsersController. I know my routing is working, because the console.log successfully logs both the loginpassword and loginname. However, the res.view() doesn't work. Neither does returning res.view(). module.exports = { create: function(req, res) { }, destroy: function(req, res) { }, login: function(req, res) { var loginname = req.param("loginname"); var loginpassword = req.param("loginpassword"); console.log(loginname + ' ' + loginpassword); res.view(); }, logout: function(req, res) { }, _config: {} }; I have a /views/user/login.ejs and all it currently contains is a header block with some test text, but I can't get that to render at all. Any thoughts?

    Read the article

  • Tutorial: Getting Started with the NoSQL JavaScript / Node.js API for MySQL Cluster

    - by Mat Keep
    Tutorial authored by Craig Russell and JD Duncan  The MySQL Cluster team are working on a new NoSQL JavaScript connector for MySQL. The objectives are simplicity and high performance for JavaScript users: - allows end-to-end JavaScript development, from the browser to the server and now to the world's most popular open source database - native "NoSQL" access to the storage layer without going first through SQL transformations and parsing. Node.js is a complete web platform built around JavaScript designed to deliver millions of client connections on commodity hardware. With the MySQL NoSQL Connector for JavaScript, Node.js users can easily add data access and persistence to their web, cloud, social and mobile applications. While the initial implementation is designed to plug and play with Node.js, the actual implementation doesn't depend heavily on Node, potentially enabling wider platform support in the future. Implementation The architecture and user interface of this connector are very different from other MySQL connectors in a major way: it is an asynchronous interface that follows the event model built into Node.js. To make it as easy as possible, we decided to use a domain object model to store the data. This allows for users to query data from the database and have a fully-instantiated object to work with, instead of having to deal with rows and columns of the database. The domain object model can have any user behavior that is desired, with the NoSQL connector providing the data from the database. To make it as fast as possible, we use a direct connection from the user's address space to the database. This approach means that no SQL (pun intended) is needed to get to the data, and no SQL server is between the user and the data. The connector is being developed to be extensible to multiple underlying database technologies, including direct, native access to both the MySQL Cluster "ndb" and InnoDB storage engines. The connector integrates the MySQL Cluster native API library directly within the Node.js platform itself, enabling developers to seamlessly couple their high performance, distributed applications with a high performance, distributed, persistence layer delivering 99.999% availability. The following sections take you through how to connect to MySQL, query the data and how to get started. Connecting to the database A Session is the main user access path to the database. You can get a Session object directly from the connector using the openSession function: var nosql = require("mysql-js"); var dbProperties = {     "implementation" : "ndb",     "database" : "test" }; nosql.openSession(dbProperties, null, onSession); The openSession function calls back into the application upon creating a Session. The Session is then used to create, delete, update, and read objects. Reading data The Session can read data from the database in a number of ways. If you simply want the data from the database, you provide a table name and the key of the row that you want. For example, consider this schema: create table employee (   id int not null primary key,   name varchar(32),   salary float ) ENGINE=ndbcluster; Since the primary key is a number, you can provide the key as a number to the find function. function onSession = function(err, session) {   if (err) {     console.log(err);     ... error handling   }   session.find('employee', 0, onData); }; function onData = function(err, data) {   if (err) {     console.log(err);     ... error handling   }   console.log('Found: ', JSON.stringify(data));   ... use data in application }; If you want to have the data stored in your own domain model, you tell the connector which table your domain model uses, by specifying an annotation, and pass your domain model to the find function. var annotations = new nosql.Annotations(); function Employee = function(id, name, salary) {   this.id = id;   this.name = name;   this.salary = salary;   this.giveRaise = function(percent) {     this.salary *= percent;   } }; annotations.mapClass(Employee, {'table' : 'employee'}); function onSession = function(err, session) {   if (err) {     console.log(err);     ... error handling   }   session.find(Employee, 0, onData); }; Updating data You can update the emp instance in memory, but to make the raise persistent, you need to write it back to the database, using the update function. function onData = function(err, emp) {   if (err) {     console.log(err);     ... error handling   }   console.log('Found: ', JSON.stringify(emp));   emp.giveRaise(0.12); // gee, thanks!   session.update(emp); // oops, session is out of scope here }; Using JavaScript can be tricky because it does not have the concept of block scope for variables. You can create a closure to handle these variables, or use a feature of the connector to remember your variables. The connector api takes a fixed number of parameters and returns a fixed number of result parameters to the callback function. But the connector will keep track of variables for you and return them to the callback. So in the above example, change the onSession function to remember the session variable, and you can refer to it in the onData function: function onSession = function(err, session) {   if (err) {     console.log(err);     ... error handling   }   session.find(Employee, 0, onData, session); }; function onData = function(err, emp, session) {   if (err) {     console.log(err);     ... error handling   }   console.log('Found: ', JSON.stringify(emp));   emp.giveRaise(0.12); // gee, thanks!   session.update(emp, onUpdate); // session is now in scope }; function onUpdate = function(err, emp) {   if (err) {     console.log(err);     ... error handling   } Inserting data Inserting data requires a mapped JavaScript user function (constructor) and a session. Create a variable and persist it: function onSession = function(err, session) {   var data = new Employee(999, 'Mat Keep', 20000000);   session.persist(data, onInsert);   } }; Deleting data To remove data from the database, use the session remove function. You use an instance of the domain object to identify the row you want to remove. Only the key field is relevant. function onSession = function(err, session) {   var key = new Employee(999);   session.remove(Employee, onDelete);   } }; More extensive queries We are working on the implementation of more extensive queries along the lines of the criteria query api. Stay tuned. How to evaluate The MySQL Connector for JavaScript is available for download from labs.mysql.com. Select the build: MySQL-Cluster-NoSQL-Connector-for-Node-js You can also clone the project on GitHub Since it is still early in development, feedback is especially valuable (so don't hesitate to leave comments on this blog, or head to the MySQL Cluster forum). Try it out and see how easy (and fast) it is to integrate MySQL Cluster into your Node.js platforms. You can learn more about other previewed functionality of MySQL Cluster 7.3 here

    Read the article

  • batch file to merge .js files from subfolders into one combined file

    - by Andrew Johns
    I'm struggling to get this to work. Plenty of examples on the web, but they all do something just slightly different to what I'm aiming to do, and every time I think I can solve it, I get hit by an error that means nothing to me. After giving up on the JSLint.VS plugin, I'm attempting to create a batch file that I can call from a Visual Studio build event, or perhaps from cruise control, which will generate JSLint warnings for a project. The final goal is to get a combined js file that I can pass to jslint, using: cscript jslint.js < tmp.js which would validate that my scripts are ready to be combined into one file for use in a js minifier, or output a bunch of errors using standard output. but the js files that would make up tmp.js are likely to be in multiple subfolders in the project, e.g: D:\_projects\trunk\web\projectname\js\somefile.debug.js D:\_projects\trunk\web\projectname\js\jquery\plugins\jquery.plugin.js The ideal solution would be to be able to call a batch file along the lines of: jslint.bat %ProjectPath% and this would then combine all the js files within the project into one temp js file. This way I would have flexibility in which project was being passed to the batch file. I've been trying to make this work with copy, xcopy, type, and echo, and using a for do loop, with dir /s etc, to make it do what I want, but whatever I try I get an error.

    Read the article

  • Are all of the default scripts loaded by Magento really needed?

    - by pxl
    Here's a listing of all the scripts loaded by Magento by default: ../js/prototype/prototype.js //prototype library ../js/prototype/validation.js //don't know what this does ../js/scriptaculous/builder.js //don't know what this does ../js/scriptaculous/effects.js //base scriptaculous effects library? ../js/scriptaculous/dragdrop.js //component of scriptaculous effects ../js/scriptaculous/controls.js //not sure? ../js/scriptaculous/slider.js //more scriptaculous effects ../js/varien/js.js //don't know what this is ../js/varien/form.js //form validation scripts? ../js/varien/menu.js //menu/drop down menu scripts ../js/mage/translate.js //don't know what this does ../js/mage/cookies.js //don't know what this does these scripts total 316.8K of javascript... all in various states of being minified (for example, prototype.js isn't minified). So my first question: 1) Aside from prototype.js, are all of the others really that needed? and 2) What is the "correct" way to remove these scripts? Layout updates? Or hardcoded in templates? I want to make the loading of my magento site as light weight as possible. thanks!

    Read the article

  • Microsoft TypeScript : A Typed Superset of JavaScript

    - by shiju
    JavaScript is gradually becoming a ubiquitous programming language for the web, and the popularity of JavaScript is increasing day by day. Earlier, JavaScript was just a language for browser. But now, we can write JavaScript apps for browser, server and mobile. With the advent of Node.js, you can build scalable, high performance apps on the server with JavaScript. But many developers, especially developers who are working with static type languages, are hating the JavaScript language due to the lack of structuring and the maintainability problems of JavaScript. Microsoft TypeScript is trying to solve some problems of JavaScript when we are building scalable JavaScript apps. Microsoft TypeScript TypeScript is Microsoft's solution for writing scalable JavaScript programs with the help of Static Types, Interfaces, Modules and Classes along with greater tooling support. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. This would be more productive for developers who are coming from static type languages. You can write scalable JavaScript  apps in TypeScript with more productive and more maintainable manner, and later you can compiles to plain JavaScript which will be run on any browser and any OS. TypeScript will work with browser based JavaScript apps and JavaScript apps that following CommonJS specification. You can use TypeScript for building HTML 5 apps, Node.JS apps, WinRT apps. TypeScript is providing better tooling support with Visual Studio, Sublime Text, Vi, Emacs. Microsoft has open sourced its TypeScript languages on CodePlex at http://typescript.codeplex.com/    Install TypeScript You can install TypeScript compiler as a Node.js package via the NPM or you can install as a Visual Studio 2012 plug-in which will enable you better tooling support within the Visual Studio IDE. Since TypeScript is distributed as a Node.JS package, and it can be installed on other OS such as Linux and MacOS. The following command will install TypeScript compiler via an npm package for node.js npm install –g typescript TypeScript provides a Visual Studio 2012 plug-in as MSI file which will install TypeScript and also provides great tooling support within the Visual Studio, that lets the developers to write TypeScript apps with greater productivity and better maintainability. You can download the Visual Studio plug-in from here Building JavaScript  apps with TypeScript You can write typed version of JavaScript programs with TypeScript and then compiles it to plain JavaScript code. The beauty of the TypeScript is that it is already JavaScript and normal JavaScript programs are valid TypeScript programs, which means that you can write normal  JavaScript code and can use typed version of JavaScript whenever you want. TypeScript files are using extension .ts and this will be compiled using a compiler named tsc. The following is a sample program written in  TypeScript greeter.ts 1: class Greeter { 2: greeting: string; 3: constructor (message: string) { 4: this.greeting = message; 5: } 6: greet() { 7: return "Hello, " + this.greeting; 8: } 9: } 10:   11: var greeter = new Greeter("world"); 12:   13: var button = document.createElement('button') 14: button.innerText = "Say Hello" 15: button.onclick = function() { 16: alert(greeter.greet()) 17: } 18:   19: document.body.appendChild(button) .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } The above program is compiling with the TypeScript compiler as shown in the below picture The TypeScript compiler will generate a JavaScript file after compiling the TypeScript program. If your TypeScript programs having any reference to other TypeScript files, it will automatically generate JavaScript files for the each referenced files. The following code block shows the compiled version of plain JavaScript  for the above greeter.ts greeter.js 1: var Greeter = (function () { 2: function Greeter(message) { 3: this.greeting = message; 4: } 5: Greeter.prototype.greet = function () { 6: return "Hello, " + this.greeting; 7: }; 8: return Greeter; 9: })(); 10: var greeter = new Greeter("world"); 11: var button = document.createElement('button'); 12: button.innerText = "Say Hello"; 13: button.onclick = function () { 14: alert(greeter.greet()); 15: }; 16: document.body.appendChild(button); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Tooling Support with Visual Studio TypeScript is providing a plug-in for Visual Studio which will provide an excellent support for writing TypeScript  programs within the Visual Studio. The following screen shot shows the Visual Studio template for TypeScript apps   The following are the few screen shots of Visual Studio IDE for TypeScript apps. Summary TypeScript is Microsoft's solution for writing scalable JavaScript apps which will solve lot of problems involved in larger JavaScript apps. I hope that this solution will attract lot of developers who are really looking for writing maintainable structured code in JavaScript, without losing any productivity. TypeScript lets developers to write JavaScript apps with the help of Static Types, Interfaces, Modules and Classes and also providing better productivity. I am a passionate developer on Node.JS and would definitely try to use TypeScript for building Node.JS apps on the Windows Azure cloud. I am really excited about to writing Node.JS apps by using TypeScript, from my favorite development IDE Visual Studio. You can follow me on twitter at @shijucv

    Read the article

  • js includes for html seo-friendly

    - by ascar
    I need to do client-side includes on a website for the navigation. The problem is the navigation is currently all html, and since I can't use php i've just been using js to include the html with document.write (). however, i read that this is not good for seo. While i know there are seo-friendly js navigation menus, I was wondering if there's a way to do this while including the html and not having to alter it very much? I also got it to work using embed with html which i know is super hacky but i don't really know that much about js and am frustrated being told not to use server side includes. thanks!!

    Read the article

  • Python or HTML5/JS for game development on 2014 [on hold]

    - by AlexKvazos
    So I've decided to give game development a go. I have experience on php/html/css/sql/js(jquery) so learning a new language shouldn't be as hard. I was reading that python and javascript are both nice for simple 2d non-intensive games. I found that python has this library/engine called PyGame but I realized that it was last updated 4 years ago. People still use this? And for javascript, I found libraries like 'pixi.js', 'melon.js' and 'cocos2d'. My goal is to make 2D games that would require the same performance as terraria, realm of the mad god, castle crashers.. and all those types of games. Taking into consideration, that I do want an updated library, what language of this two would be best to choose and what library to grab for it? Thanks in advance, sorry if question is broad. Let me know and I can edit to add more.

    Read the article

  • What is So Unique About Node.js?

    - by Adrian Shum
    Recently there has been a lot of praise for Node.js. I am not a developer that has had much exposure to network application. From my bare understanding of Nodes.js, its strength is: we have only one thread handling multiple connections, providing an event-based architecture. However, for example in Java, I can create only one thread using NIO/AIO (which is non-blocking APIs from my bare understanding), and handle multiple connections using that thread, and I provide an event-based architecture to implement the data handling logic (shouldn't be that difficult by providing some callback etc) ? Given JVM being a even more mature VM than V8 (I expect it to run faster too), and event-based handling architecture seems to be something not difficult to create, I am not sure why Node.js is attracting so much attention. Did I miss some important points?

    Read the article

  • Why Nodes.js being that "unique"?

    - by Adrian Shum
    Recently years there are lots of praise to Nodes.js. I am not a developer that have much exposure on network application. From my bare understanding of Nodes.js, its strength is: We are having only on thread handling multiple connections, providing a event-based architecture. However, for example in Java, what if I am having only one thread, using NIO/AIO (which is non-blocking APIs from my bare understanding), and handle multiple connections using that thread, and I provide an event-based architecture to implement the data handling logic (shouldn't be that difficult by providing some callback etc) ? Given JVM being a even more mature VM than V8 (I expect it run faster too), and event-based handling architecture seems not something difficult to create. I am not sure why Nodes.js is attracting so much attention. Did I miss some important points?

    Read the article

  • Where does node.js install to?

    - by Ash Scott
    I'm trying to install a script, which is a clone of a game, and uses node.js for it. Now, the documentation says I should copy the node.exe (windows) and put it where the clone is. Now, I can't find the node.exe ubuntu equivalent, I can't even find where it's installed?! Don't really want this hosted on a windows machine due to licensing. Here's a snipet from the doc: Download : Node.js (Install Button) Go where you are install Node.js (For Windows 8 it's C:/Programms/nodejs) Copy node.exe and paste on the clone folder Now I need to do this in ubuntu, however I can't find where node is installed to? Any ideas?

    Read the article

  • jQuery scrolling images for e-commerce site, what to do about users who disable JS

    - by Livingston Storm
    As the title suggests, I am developing an e-commerce site and I intend of having two jQuery plug ins on the default page, one for scrolling images and the other for the navigation menu. Should I be concerned about making the site work if the users disables JS? Cause if they have it disabled my site would be almost impossible to use with the scrolling images blocking the main content. Plus the CMS I am using, Big Commerce, uses a bit of JS for the products pages, which would also look ridiculous with JS disabled. Anyone have experience with this?

    Read the article

  • How to disable pdf.js in Firefox !

    - by Anirudha
    Originally posted on: http://geekswithblogs.net/anirugu/archive/2013/06/27/how-to-disable-pdf.js-in-firefox.aspxFrom last few version  Firefox natively have integration of Pdf.js. Sometime you (maybe) feel that it’s run very slow. very slow to scroll down the PDF. Now you want to disable it.   How you can do it.   Here is the settings In my system I have installed Adobe Reader. First option is going to open the file in Adobe reader and second (that I selected) is about to open in firefox itself. Now Slow performed pdf.js problem is gone

    Read the article

  • Update graph in real time from server

    - by user1869421
    I'm trying to update a graph with received data, so that the height of the bars increase as more data is received from the server via a websocket. But my code doesn't render a graph in the browser and plot the data points. I cannot see anything wrong with the code. I really need some help here please. ws = new WebSocket("ws://localhost:8888/dh"); var useData = [] //var chart; var chart = d3.select("body") .append("svg:svg") .attr("class", "chart") .attr("width", 420) .attr("height", 200); ws.onmessage = function(evt) { var distances = JSON.parse(evt.data); data = distances.miles; console.log(data); if(useData.length <= 10){ useData.push(data) } else { var draw = function(data){ // Set the width relative to max data value var x = d3.scale.linear() .domain([0, d3.max(useData)]) .range([0, 420]); var y = d3.scale.ordinal() .domain(useData) .rangeBands([0, 120]); var rect = chart.selectAll("rect") .data(useData) // enter rect rect.enter().append("svg:rect") .attr("y", y) .attr("width", x) .attr("height", y.rangeBand()); // update rect rect .attr("y", y) .attr("width", x) .attr("height", y.rangeBand()); var text = chart.selectAll("text") .data(useData) // enter text text.enter().append("svg:text") .attr("x", x) .attr("y", function (d) { return y(d) + y.rangeBand() / 2; }) .attr("dx", -3) // padding-right .attr("dy", ".35em") // vertical-align: middle .attr("text-anchor", "end") // text-align: right .text(String); // update text text .data(useData) .attr("x", x) .text(String); } useData.length = 0; } } Thanks

    Read the article

  • Calling javascript class within other Js

    - by harigm
    I have Aptana plugin in eclipse, I have a javascript (one.js) and i have included one more Javscript(two.js) within one.js. I click on any functions within one.js and if those functions exists in the same one.js, the control is going to the respective function. Suppose if the function exists in two.js, the control is not going to two.js Can any one help me with this?

    Read the article

  • Scaling a node.js application, nginx as a base server, but varnish or redis for caching?

    - by AntelopeSalad
    I'm not close to being well versed in using nginx or varnish but this is my setup at the moment. I have a node.js server running which is serving either json, html templates, or socket.io events. Then I have nginx running in front of node which is serving all static content (css, js, etc.). At this point I would like to cache both static content and dynamic content to memory. It's to my understanding that varnish can cache static content quite well and it wouldn't require touching my application code. I also think it's capable of caching dynamic content too but there cannot be any cookie headers? I do use redis at the moment for holding session data and planned to use it for other things in the future like keeping track of non-crucial but fun stats. I just have no idea how I should handle caching everything on the site. I think it comes down to these options but there might be more: Throw varnish in front of nginx and let varnish cache static pages, no app code changes. Redis would cache dynamic db calls which would require modifying my app code. Ignore using varnish completely and let redis handle caching everything, then use one of the nginx-redis modules. I'm not sure if this would require a lot of app code changes (for the static files). I'm not having any luck finding benchmarks that compare nginx+varnish vs nginx+redis and I'm too inexperienced to bench it myself (high chances of my configs being awful). I'm basically looking for the solution that would be the most efficient in terms of req/sec and scalable in the future (throw new hardware at the problem + maybe adjust some values in a config = new servers up and running semi-painlessly).

    Read the article

  • Integration Patterns with Azure Service Bus Relay, Part 3.5: Node.js relay

    - by Elton Stoneman
    This is an extension to Part 3 in the IPASBR series, see also: Integration Patterns with Azure Service Bus Relay, Part 1: Exposing the on-premise service Integration Patterns with Azure Service Bus Relay, Part 2: Anonymous full-trust .NET consumer Integration Patterns with Azure Service Bus Relay, Part 3: Anonymous partial-trust consumer In Part 3 I said “there isn't actually a .NET requirement here”, and this post just follows up on that statement. In Part 3 we had an ASP.NET MVC Website making a REST call to an Azure Service Bus service; to show that the REST stuff is really interoperable, in this version we use Node.js to make the secure service call. The code is on GitHub here: IPASBR Part 3.5. The sample code is simpler than Part 3 - rather than code up a UI in Node.js, the sample just relays the REST service call out to Azure. The steps are the same as Part 3: REST call to ACS with the service identity credentials, which returns an SWT; REST call to Azure Service Bus Relay, presenting the SWT; request gets relayed to the on-premise service. In Node.js the authentication step looks like this: var options = { host: acs.namespace() + '-sb.accesscontrol.windows.net', path: '/WRAPv0.9/', method: 'POST' }; var values = { wrap_name: acs.issuerName(), wrap_password: acs.issuerSecret(), wrap_scope: 'http://' + acs.namespace() + '.servicebus.windows.net/' }; var req = https.request(options, function (res) { console.log("statusCode: ", res.statusCode); console.log("headers: ", res.headers); res.on('data', function (d) { var token = qs.parse(d.toString('utf8')); callback(token.wrap_access_token); }); }); req.write(qs.stringify(values)); req.end(); Once we have the token, we can wrap it up into an Authorization header and pass it to the Service Bus call: token = 'WRAP access_token=\"' + swt + '\"'; //... var reqHeaders = { Authorization: token }; var options = { host: acs.namespace() + '.servicebus.windows.net', path: '/rest/reverse?string=' + requestUrl.query.string, headers: reqHeaders }; var req = https.request(options, function (res) { console.log("statusCode: ", res.statusCode); console.log("headers: ", res.headers); response.writeHead(res.statusCode, res.headers); res.on('data', function (d) { var reversed = d.toString('utf8') console.log('svc returned: ' + d.toString('utf8')); response.end(reversed); }); }); req.end(); Running the sample Usual routine to add your own Azure details into Solution Items\AzureConnectionDetails.xml and “Run Custom Tool” on the .tt files. Build and you should be able to navigate to the on-premise service at http://localhost/Sixeyed.Ipasbr.Services/FormatService.svc/rest/reverse?string=abc123 and get a string response, going to the service direct. Install Node.js (v0.8.14 at time of writing), run FormatServiceRelay.cmd, navigate to http://localhost:8013/reverse?string=abc123, and you should get exactly the same response but through Node.js, via Azure Service Bus Relay to your on-premise service. The console logs the WRAP token returned from ACS and the response from Azure Service Bus Relay which it forwards:

    Read the article

  • Is there a solution that lets Node.js act as an HTTP reverse proxy?

    - by Igor Zinov'yev
    Our company has a project that right now uses nginx as a reverse proxy for serving static content and supporting comet connections. We use long polling connections to get rid of constant refresh requests and let users get updates immediately. Now, I know there is a lot of code already written for Node.js, but is there a solution that lets Node.js act as a reverse proxy for serving static content as nginx does? Or maybe there is a framework that allows to quickly develop such a layer using Node.js?

    Read the article

  • transition of x-axis results in overflow

    - by peter
    First of all, no: this question is not about the (yet) ugly transition of the lines (I might open another one for that, though..). I'm displaying data in line charts and the user can select the time horizon. The x-axis then correspondingly transitions so as to fit to the changed time horizon. In attached image, e.g., the time horizon was 1 week and then I switched to 4 weeks. The number of ticks on the x-axis increases from 7 to 28, correspondingly. Question: How can I prevent the x-axis animation to display outside the svg container? As you can see, the additional dates fly in from the left and they are being animated far far outside the container. Any ideas? Right now, the transition works probably in the most simple way it could: // format for x-axis var xAxis = d3.svg.axis() .scale(x) .orient("bottom") .tickFormat(d3.time.format("%d.%m")) .ticks(d3.time.days, 1) .tickSubdivide(0); // Update x-axis svg.select(".x") .transition() .duration(500) .call(xAxis);

    Read the article

  • JavaScript: How can I delay running some JS code until ALL of my asynchronous JS files downloaded?

    - by Henryh
    UPDATE: I have the following code: <script type="text/javascript"> function addScript(url) { var script = document.createElement('script'); script.src = url; document.getElementsByTagName('head')[0].appendChild(script); } addScript('http://example.com/One.js'); addScript('http://example.com/Two.js'); addScript('http://example.com/Three.js'); addScript('http://example.com/Four.js'); ... // run code below this point once both Two.js & Three.js has been downloaded and excuted </script> How can I prevent code from executing until all required JS have been downloaded and executed? In my example above, those required files being Two.js and Three.js.

    Read the article

  • No method 'get' on backbone model save

    - by user888734
    I'm using backbone for a reasonably complicated form. I have a number of nested models, and have been computing other variables in the parent model like so: // INSIDE PARENT MODEL computedValue: function () { var value = this.get('childModel').get('childModelProperty'); return value; } This seems to work fine for keeping my UI in sync, but as soon as I call .save() on the parent model, I get: Uncaught TypeError: Object #<Object> has no method 'get' It seems that the child model kind of temporarily stops responding. Am I doing something inherently wrong? EDIT: The stack trace is: Uncaught TypeError: Object #<Object> has no method 'get' publish.js:90 Backbone.Model.extend.neutralDivisionComputer publish.js:90 Backbone.Model.extend.setNeutralComputed publish.js:39 Backbone.Events.trigger backbone.js:163 _.extend.change backbone.js:473 _.extend.set backbone.js:314 _.extend.save.options.success backbone.js:385 f.Callbacks.o jquery.min.js:2 f.Callbacks.p.fireWith jquery.min.js:2 w jquery.min.js:4 f.support.ajax.f.ajaxTransport.send.d

    Read the article

  • In Node.js, how can I load my modules once and then use them throughout the app?

    - by TIMEX
    I want to create one global module file, and then have all my files require that global module file. Inside that file, I would load all the modules once and export a dictionary of loaded modules. How can I do that? I actually tried creating this file...and every time I require('global_modules'), all the modules kept reloading. It's O(n). I want the file to be something like this (but it doesn't work): //global_modules.js - only load these one time var modules = { account_controller: '/account/controller.js', account_middleware: '/account/middleware.js', products_controller: '/products/controller.js', ... } exports.modules = modules;

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >