Erlang, connecting nodes across the internet in Erlang - concurrency

I've started playing alittle with erlang, and find it most interesting.
My problem is this, I would like to set up a server to run a webservice. The service should be writen in erlang, and should be easily mutated, that Is I would like to be able to do hot codeswap alot, the code is writen and tested on another machine, it there a way to deploy code easily from one erlang noce to another, without having to wrap it up in files and transfer the files?
I think I remmember hearing something about being able to pass closures around inside the erlang VM, is this doable? or perhaps even updating threads on the server machine with the compiled code on the development machine?
I know this sounds like a risky way of doing things, and it is, but its what my mind has settled on.

if I understand correctly, you want to load a module from one node to another. In this case you can use the bif nl(Module) which loads the module "Module" on all nodes. Or you can either use nc(Module) Of course the nodes must share the same cookie and must be connected (see net_adm:ping(Node))

You can't really get away from transferring files to your target deployment machine. At the very least your going to need to send down the new versions of the modules.
Once you have updated the modules your options for updating code of the fly range from simply reloading a module (something like code:load_file/1). A full blown OTP upgrade (rebar may help here) or something in-between (like updo or the mochiweb reloader module). It really depends on what you are trying to do, the dependencies between the changed modules, etc.

Related

test output of clojure functions visually in a browser

I'm developing a Clojure application, which downloads images from the web and analyzes them for certain criteria.
Whatever this might mean, the important part is, that there will be some quite expensive functions in the app, which take a while until they are processed.
In the end, there will be an API that exposes the app's functionality to a web frontend. This is meant to be a second step though.
Since the app has a lot to do with graphics, it makes sense to visualize the outputs of the functions I'm writing during the development process.
Basically I'm looking for an easy way / environment to archive this.
More precisely: Whenever I created a new function, I want to test it's functionality inside a browser: E.g. plot the output, draw some intermediate steps, maybe create some small interactive scripts, that help me to supervise that the algorithms are doing what I intend to. Note: I don't want to to transform the functions to ClojureScript and let them run in the browser, the browser should be just a "display".
Some approaches that came to my mind:
Writing a little backend-server that exposes all the functions of a namespace. So the front-end could access all these functions simply by sending an ajax request to the server, that includes the function and it's parameters in a string, or maybe better in edn format. The back-end receives the request, calls the requested function and sends back the result whenever the calculation is done. Is there maybe already a project, that does exactly this?
Using a project like "Gorilla Repl" This would be a good option, and maybe I'm going to use it. However, I could not yet figure out if it's mechanism covers a way to interactively influence the rendered outputs. It rather works as a worksheet with static renderings.
How would you guys do this? Any suggestions are appreciated.
I have been working on similar problems and I think that you could use the combination of Lighttable + Clojure + Nerdy-painter (plugin).
Nerdy-painter allows you to display images on Lighttable (IDE). Very useful for data exploration or anything that has to do with graphics/plots.
Disclaimer: I am the author of nerdy-painter, still I think the fastest/elegant solution is the one I described above. All other solutions add (IMHO) too much overhead to the development cycle.
A possibility is to use a Jupyter's clojure kernel to interact with clojure. Jupyter runs in a browser and you can add custom binding to simplify access to the DOM.
Here's a clojure kernel: https://github.com/roryk/clojupyter

how to run lamp in env

TL;DR
How do I encapsulate my Apache/PHP/MySQL/Wordpress installation in an environment or sandbox?
In my absence the designers-that-be have decreed that we use Wordpress for our newest project, as opposed to the Django-type applications I am familiar with. Another developer has already started making a custom theme, but now he's gone and I'm supposed to take over his work but I have no experience whatsoever with LAMP or Wordpress.
I thought it would be a good start to encapsulate the project into a proper standalone repository that I can copy and share between machines and people, put on github, etc, and most importantly: it needs to run in a virtual-env instance (or equivalent), so it doesn't mess up anybody's other projects, we can run multiple versions, etc.
Can anybody help me with that? At the moment it looks like the required files are spread out over my whole computer, I keep having to touch stuff in my root-directory, I need sudo simply to start and stop the *##+ing server, it's complete lunacy.
Thank you!
Take a look at virtPHP, phpenv and php-build for creating isolated environments. As for typing sudo every time you need to start or stop the server, this is the right way of doing things.

Reliable way to wrap Node.js+Socket.io into OSX executable? (or C/C++/Objective-C libraries to use as alternatives)

I'm working on a project that needs a simple, lightweight event server (i.e. a server that passes events between different client applications implemented in Javascript). At first Node.js and Socket.io seemed like the perfect solution but the amount of dependencies and config involved took some of the shine off (see below for details on the project and why configuration is an issue). Is there some tested and reliable way to package all those dependencies into a single executable that can be run with no additional configuration? If not are there any good C/C++ Websockets libraries that could be combined with something like Mongoose to create a standalone executable?
Project Details
Basic use case:
A moderator turns on the server on their OSX machine.
A group of 10-20 users point their mobile devices to a site hosted on the moderator's machine
Communication ensues for the duration of the session (about an hour)
Basic requirements:
Simple setup: The moderator will not be a developer and may have little to no technical expertise. Anything that requires the terminal or fiddling with configuration files or package managers is a non-starter.
Unreliable Configuration: The moderator's machine will be used in a lot of different contexts and by a lot of different users. Therefore the system shouldn't rely on very specific or pristine settings (i.e. would like to avoid something with lots of dependencies that requires special environment variables to be set)
Performance and security are not a concern: The server will run locally with small number of trusted users for a short time so security and high performance aren't important.
Interesting question.
I know there are some C and/or C++ WebSocket libraries under development in the WebSocket community (mentioned on the IETF discussion list) if you want to go in that direction.
It might interest you to know that some parts of Node.js are actually written in javascript and compiled during the build process as built-in modules, but I don't know of any way to accomplish that for your own code short of hacking up the build.
Since this is OSX you could package Node alongside your own code and any modules, built against a static v8 library, in your .app. This would be a fairly tight coupling though not quite what you are asking for.
It's also possible to build your extension (or part of it) as a C++ module loaded by Node and v8.

Can an application pretend to be a file or folder?

I've been looking into centralising my computer game saves to make it easier to backup and restore as well as putting them up on the cloud via dropbox but there in so may places that it makes it quite difficult. I noticed the Windows 7 and Vista now support Symbolic links so I've been playing around with that but I was wonder the follow:
Is it possible (code example or a point in the right direction) for an application (vb.net or C++) to spoof a file or folder?
E.g. Application A (a game like Diablo III or Civilization V) attempts to read or right from file A (the game save), application B (the save repository) detects this read/write request and pipes the request through itself preforming the request on file B (the actual game save in another location). Application A is in no way altered and treats the file normally.
Note: I realise there are many simple ways of preforming the same task in essence such as monitoring the use of Application A or periodically checking file A and copying it if it has been altered since the last check etc but all these methods have draw backs and less interested in making it work than if it is possible.
It is entirely possible to do this through a file system filter driver. For information about these, take a look here:
http://msdn.microsoft.com/en-us/windows/hardware/gg462968
Filter drivers can hook into CreateFile operations and redirect the create to a different place if you want, but they are much harder to write as compared to normal applications. They run in kernel mode and must obey the limitations of drivers.
You can "fake" special folders, like control panel does, but I don't think you can create anything accessible/writeable (in an easy way). I might be wrong though. I had the same idea once too (as a compatibility step for some company stuff), but couldn't find anything supporting an easy way to do it. It seems like it might be easier to be done on Unix systems (but that's obviously no option here). Also, I wouldn't expect any nice or easy solutions for .net.
Only approach I could think about right now, would be highjacking the according API calls (e.g. FileOpen) to reroute/manipipulate them (similar to what root kits do), but I wouldn't say that's a good idea, considering it might be detected as possible malware or cheats by things like punkbuster or antivirus solutions.
Yes or no depending on (using your terms) the level of abstraction that Application A is using.
If Application A is performing a CreateFile wto start access and passing a fixed filesystem path then Application B would need to emulate a file system and do so in the kernel.
On the other hand if Application A were to user HTTP with RESTful URLs then the HTTP server could answer all requests from files or by dynamically creating the content.
So the question can only be answered in specific by knowing the details of Application A.

Initializing ArcEngine, Make it Faster?

I am currently working on a C++/COM project using ArcEngine(From ESRI). Aside from the fact that there is little to no support in terms of documentation (SDK is there.) Anyways, i am wondering if anyone here has had any experience in making the initialization process of ArcEngine faster. Right now it takes 30-35 seconds just to initialize the engine. Now we are going to be running several of these applications. Does anyone have any experience, with this?
Its a very werid and odd task, but ESRI's developer forums are no help. and i couldnt find anything on google.
Any ideas?
It's been almost a decade since I last played with ESRI stuff, so I can't help you with anything specific to ArcEngine.
Maybe you can pool instances? In the best case scenario you would be able to reuse ArcEngine instances, and could return an instance back to pool after you're done with it.
If that's not possible, you could at least try to have a number of instances ready to roll, although whether that is possible and/or useful depends a lot on the specifics of your app.
Is it really COM? In that case, the ArcEngine will be exposing a set of COM interfaces. COM interfaces are not magic, and not uniquely bound to one program. In fact, COM has explicit support for proxying. This is e.g. used by DCOM; you get a local proxy for the remote server.
In this case, it should be possible to write a custom COM proxy that fakes the initialization stuff but forwards everything else. Towards your client, the proxies COM interface is identical except faster. Towards ArcEngine, your proxy can wait quite long between calls.
Something that I have found useful with getting ESRI products to start faster (not necessarily ArcEngine, but this probably applies) is to specify the port number (generally 27004) in the registry where the license server is defined.
HKEY_LOCAL_MACHINE\SOFTWARE\ESRI\License\LICENSE_SERVER
HKEY_LOCAL_MACHINE\SOFTWARE\ESRI\ArcInfo\Workstation\8.0\LICENSE_SERVER
When you set this in installation or through the desktop administrator, it is generally something like: #yourserver.name
Change this to 27004#yourserver.name
Again this may not solve your issue, but if you're not doing it, it's worth a try. I've found it to speed things up in our environment, both using a license manager on a network and with a hardware dongle on the local machine.
Well from my understanding ArcEngine initialization, initializes a special COM environment.
You don't ever get any sort of real handle over the initialized environment. Can you somehow store a COM Enviroment and pass it to other programs. My current idea is:
Windows Service Running in Background with initialized ArcEngine. Program somehow queries the service, the service returns the COM Enviroment. Is this even possible?
I had a lot of grief with ESRI forums providing very little help. It feels like Arc* developers are largely on their own.
Using ArcEngine + .Net the initialization time for an application has been trivial (maybe 1 second?) in our environment -- are you using a slow remote server or is this JUST the engine with no network or maps being loaded?
Whenever I've had to deal with large data sets, ESRI has a pig though.
Good to see some discussion on SO of ESRI products! Not a lot here yet...
Exactly what line is taking 45 seconds? If I had to do some psychic debugging, I would guess that you are running into a problem with your license server.
Check that first.