SqlTableDependency for nodejs? - javascript

in my application in node I run a query every 30 seconds to get data from my sql server database.
However I want my app to be real time, i saw there is something that is called "SqlTableDependency" in asp.net that do exactly what I need.
The package "SqlTableDependency" listens to the database and send notifications whenever the table change.
I want to know if there is a package in node that does anything similar.
Thank you for the help!

you can go for EDGE.js this link which is a bridge between node and c#. Basically you can execute c# code through node code by importing a module called edge.
You can get more tutorial stuff on this link.
I am also looking for a complete replacement of c#.

Related

Running NodeJS Code from HTML

So I have just been getting into learning NodeJS as part of learning how to build a webscraping tool for a project I wanted to make.
I have all the content I need from the NodeJS file when I run the file directly through the terminal, but I wanted to know how to run the code directly from a website I am building to display the content I get from webscraping.
Any and all help is appreciated!
(Also I am new to stackoverflow, so if you need any more info then I would be glad to help!)
Since Node.js runs on server side, you need to call the Node.js server through ajax and get the response back.
This website shows how to do Web Scraping in Node.js, now when you get the data pass it as a response to the browser.
You may also check Express.js which gives you "Fast, unopinionated, minimalist web framework for Node.js".
So you have working node application written in javascript. Perfect.
Now you want to run that in browser mode. you can use browserify for the same. Browserify will package all the nodejs module in a bundle and let you require from the browser.
Not exactly sure if this is what you are looking for, but you should look into a cloud9 space (its free) and using express to render the HTML. It's pretty straightforward.
I think Nodejs tutorial in tutorialspoint [http://www.tutorialspoint.com/nodejs/] is powerful solution. It is just advice.

CLI based node chat app

I am wondering how I would go about making a command line interface chat app using nodejs. I could just make one using http and then use something like phantomjs to read it back into the terminal. However I am sure that there is a better way to do this.
Thanks!
-Zoe
Try this:
https://code.tutsplus.com/tutorials/real-time-chat-with-nodejs-readline-socketio--cms-20953
Node.js has an under-appreciated module in its standard library that is surprisingly useful. The Readline module does what it says on the box: it reads a line of input from the terminal. This can be used to ask the user a question or two, or to create a prompt at the bottom of the screen.
You can then use Socket.io as the server.
Node.js is a server-based Javascript.
It will be better if you can use another programming language for client and connect it to NodeJS Server.

How to use python in a JS based app

I have created an app using meteor.js framework. I need to run some python code for some important data crunching that will be used in the app. How can I do that? I am really new to Javascript and cant figure this out. I will be running python code on server. All I need is, as soon as I click a particular button, a piece of python code gets compiled.
You'll need to expose your Python code over some sort of API. Since your Python is "running on the server" as you mentioned.
The fastest way I can think of doing it is to setup an AWS Lambda function (https://aws.amazon.com/lambda/), then expose it as an API route using AWS API Gateway(https://aws.amazon.com/api-gateway/).
Once your "number crunching" is completed, you'll need to return the relevant variables back to your client app. JSON is probably a good choice for this.

Possible Autoit-like JavaScript macros?

The title says it all. Is there a way to write macros in JavaScript to achieve a similar functionality to that of Autoit? I just would want to manipulate files on my own computer (offline) and could easily do it with autoit, but since I am currently learning JavaScript -- plan to develop in Node.js -- I figure it wouldn't hurt to get the extra practice.
Thanks guys!
Use an application which supports JavaScript as a shell scripting language, such as the following:
JsRoboKey
PowershellJS
PowerChakra
RemoteNodeJS
JScript + WSH
JavaScript Shell Scripting with JSC
QtScript: QScriptEngine
Part I: How to Choose a JavaScript Engine for iOS and Android Development - OpenAphid-Engine
nodejs has a module which do autoit things --
nodejs install autoit
var au = require('autoit');
au.Init();
au.Run("notepad.exe");
au.WinWait("[Class:Notepad]");
au.Send("Hello, autoit & nodejs!");
NodeJS is a very powerfull platform, it is extensible and opensource.
There is no problem to run local scripts to do everything you need using JavaScript (see standard FileSystem library docs). You can also try to look in NPM(NodeJS package manager).
Assuming you have AutoIt installed (say in folder C:\AU3) and this folder in the PATH, you can add
extension '.AU3' to the PATHEXT environment variable, and create an AutoIt script called, say,
hello.au3 with just a silly line:
MsgBox(0, "Warning", "Hello, World!")
Now, simply typing the command 'hello' will execute the script, displaying the silly message in a modal message box.
Next, create an equally silly Node.js script, say, MyWarn.js - in the same folder:
var oCP = require("child_process");
console.log("Starting...");
var oNP = oCP.execSync("hello");
console.log("Done.");
Assuming Node is also in the PATH, try this command:
node MyWarn
So ... we get the benefits of Node (for its jit), and the benefits of AutoIt (for its GUI handling.)
The problem is getting the two to communicate. Personally, I use a RamDisk to pass small files...
Javascript can't write to a file on your local machine remotely.. Its almost the same as HTML in a view model.
It can however perform some executions of other scripts via AJAX for example. But thats on server again.
It might be worth a look to read on server && client side differences.
im not 100% sure but node might offer another outlet on this but it would still be server side.. Not locally.
The Server - This party is responsible for serving pages and handling the logic | Code behind.
The Client - This party requests pages from the Server, and displays them to the user. On most cases, the client is a web browser.
The User - The user uses the Client in order to surf the web, fill in forms, watch videos online, etc.

replace windows cmd call to .bat for and web based GUI?

to upload new changes into our server i have to type something like
uploadTemplates.bat templateid userid password integrationorProductionVar + ENTER
Thas fine but first i need to navigate to the folder where the .bat is,
Question is: can i change all this for a more automatized GUI?? if so, how?
for example a Form asking
user, pass, templateid and integrationorPrdoductionVar (as a select) and it opens the .bat on the background ?
Well, you could do it in PHP if the PHP server runs on the machine where the .bat file is. In order to call a shell command, you can use system:
system("uploadTemplates.bat {$_POST['templateid']} {$_POST['userid']} {$_POST['password']} {$_POST['integrationorProductionVar']}");
Note that since this should run on the same system and is only to be used by you, you can get away with not sanitize your data, but normally, you want to escape your shell arguments with escapeshellarg and do as much checking as possible so that someone can't exploit this and run malicious commands on the system.
I'm presuming by this question you don't have much in the way of coding experience. JavaScript isn't a language that'll be much use for this.
Download yourself a copy of Visual Express and depending on how brave you're feeling, download either Visual Basic or C# and look at a couple of tutorials.
What you're after is very basic to implement and even without any experience at all would take you under an hour to create I reckon.

Categories