LightTable creates connection per file - clojure

How can I tell LightTable which connection to use to evaluate code?
Before latest version, it created one connection upon first evaluation and then used the connection for all subsequent evals. Now it creates connection per file I evaluate form in + if I launch instarepl, it creates also new connection for it too :(
If I use remote repl, it connects to the repl successfully, but still creates new connections for each clojure file(

You didn't say what versions represented the 'before' and 'after'.
If you've moved to LightTable 0.8.x then you should update the Clojure Plugin to 0.3.2. which fixes this problem as described in the CHANGELOG.

Well, deleting all LightTable's settings (~/.config/LightTable folder on debian) helped.

Related

Execute Clojure block (or selection) doesn't work in Atom proto-repl

I've installed a fresh version of Atom 1.9.9 on Windows and set it up as described in Atom Clojure Setup.
When trying to execute a block of code in REPL, as per this explanation in its startup:
ctrl-alt-, then b Execute block. Finds the block of Clojure code your
cursor is in and executes that.
ctrl-alt-, s Executes the selection. Sends the selected text to the
REPL.
no execution happens, instead the cursor just moves backwards.
Atom key binding resolver seems to link this key combination to the atom-text-editor emacs.json behavior, however this behavior is not mentioned in the above setup guide.
Also, the key bindings are not showing for the proto-repl package in the menu, my understanding is that they should as they do for other Atom packages:
Are these normal deficiencies with Atom proto-repl package on Windows or am I missing some important additional setting?
If it's not executing the Proto REPL command it's likely that the key binding is already used by another set of keys. Atom has a great tool for investigating key binding problems called the key binding resolver. Can you enable the keybinding resolver and see what's triggered with the keybinding. Keybindings can be a pain because of conflicts among many packages.
Keybindings can be customized too. See the keybindings in the Proto REPL repo https://github.com/jasongilman/proto-repl/blob/master/keymaps/proto-repl.cson these can be added to your own keybinding file with changes that avoid conflicts with other packages you use.
You can also ask questions on Proto REPL in the Clojure slack channel #protorepl.

Clojure Light Table client-server approach riddle

How can I set it up, so that I can use Light Table on the Mac, connected to a Ubuntu-hosted nREPL, and create a new program/project.clj? Can anybody help me to understand what my approach should be, and where I'm going wrong?
I have a Ubuntu server, in VirtualBox, along with Leiningen, Pedestal, and a pedestal 'helloworld' sample program, that displays in a browser. I just can't connect to the same REPL that runs the helloworld program. I don't have client-side access or control to the server-side object.
I want to do client-server Clojure development from my Mac host LT, creating server-side programs, that I can view in a REPL.
I don't find LT to be intuitive in this area, and the advice I've read only suggests that LT will connect to an existing project/REPL. I want to create new objects, from the client
Assuming you are talking mostly about the server side of things (don't know much yet about ClojureScript), here is how you would setup a new project and code interactively against a remote repl.
lein new project-name in your VM.
Setup your project.clj the way you want it. You must include dependencies!
Start the REPL in your VM and note the port number
Commit your code to version control (git).
Checkout the same codebase for editing in LightTable in Mac OSX.
Connect to the remote REPL.
Open core.clj or create a new namespace file and start hacking.
Evaluate your code snippets or the entire file.
There are a couple of potential problems I foresee with this. First is that whenever you add a dependency, you will need to commit the change to version control, synchronize your VM working copy, restart your REPL, and reconnect LightTable to the remote REPL.
Second, you may have problems as the project grows beyond a few namespaces. I believe if your namespace requires another namespace from your project, the remote REPL process will (I think) try to load it off it's local classpath. If the dependency is not there or has changed, I don't think LightTable is smart enough to send the required namespaces over the wire. Try it out and let us know what the actual behavior is.

Why is build time of local application affected by network?

Build time of XPages application containing several JARs, Java sources and ~50 XP/CC elements takes about minute to build on server via WAN. I have replicated application to local, build time dropped to ~10s.
Since few days ago build of local application is extremely slow, about 2-5 minutes. After some experiments there is workaround: to disable TCP port in location document - it drops build times to just few seconds. Even tho it works, it does not help much - testing requires user to be authenticated, so I need to replicate design changes to remote or local server - and that means to change location (online/offline) every time.
UPDATE 2013-04-04: I have duplicated my current location document and removed home and directory servers. To my surprise, with this location build times went back to few seconds - with TCP port enabled so replication is possible. Bigger surprise was the fact, that returning home/directory servers back to new location did not reproduce the problem - in fact they do not affect performance. I know it because I have renamed current location document and everything went to normal. From my understanding, "something" in client configuration was connected to location name. Thanks to Simon's tips I will investigate further.
The question is still open: I am looking for some (eclipse) preference controlling this behavior - unintended communication with server during build of local application.
Solution:
Teamstudio CIAO hooks into designer and checks for every update of design element. Seems to be lack of code optimization to me: it checks whether currently built design element (every single one, one by one) should be controlled in CIAO config database.
This explains why the problem was solved by renaming of location document. I was disappointed yesterday, when performance problems started again. Fortunately, I recalled CIAO setup to that location document about that time. CIAO uses teamstudio.ini file in DATA directory to configure what CIAO configuration database is used for every location document. Look for entry:
CIAOConfigDb[location name]=server name;CIAO\CIAOConfig.nsf
For development on local replicas with connection to server (for replication or local server), use location document with CIAO disabled.
This works only with property ForceConfigLocation=0.
Not a solution (yet!), but may help in the investigation. I'll update further if you post results later.
Debug instructions.
Add the following to the shortcut that launches the Designer client.
-RPARAMS -console -debug -separateSysLogFiles -consoleLog
Start the designer client. This will also open up the OSGi console.
Reproduce the issue. While it is still in progress in the OSGi console type the following:
dump threads
Do this three times, with a small amount of time between completion of each dump. Once done open the three heap dumps (in the IBM_TECHNICAL_SUPPORT folder) in the Heap Dump Analyser.
It will show you what threads are consistent through all three dumps. Take a look at those and look for package names/calls which may appear to be a functional area. Once you have that then you can try adding the debug for the related class.
For example: Let's say you notice "com.ibm.designer.domino.ui.commons." in the thread, then you would edit the rcpinstall.properties file. It will be in:
<Notes Install>\Data\workspace\.config\rcpinstall.properties
and you would add (start with FINE, then FINEST if nothing):
com.ibm.designer.domino.ui.commons.level=FINE
Now when you restart the designer client it will generate debug output in the workspace\logs folder for that package. You need to then go through the trace logs looking for the time when the delay occurred and see if it makes any references to related design elements.
Other open applications may get built at the same time (which looks like a bug top me). Be sure to close all other applications and the server based replica. Open applications have their icon showing in the application list and they stay open even if you close and reopen the Designer. In Designer 9 right click application and select "Close Application". In 8.5 you need to use Package Exprorer for closing.
Another good way is to use Working Sets. Only applications in open Working Set will be built (AFAIK). Have a Working Set with this one app only (and the app only in this Working Set).
update 1
If these don't help I would delete/rename bookmark.nsf, Cache.NDK and desktop8.ndk. Then open just this one app and see what happens.
update 2
Check that there are no referenced projects. Right click the application and select "Project Properties". From there "Project Referencies" and make sure no check boxes are checked.
update 3
Based on your update I would check the item names starting with $ in location document. Sometimes there are saved IP addresses etc. which could cause this problem. All those items can be removed.
If possible (and if You are not using it yet) try to use version 9 of the Domino designer (You do not have to use Domino 9 to do that - it works fine with Domino 8.5.3).
For our projects build times went down to only few seconds from few minutes. I guess that they finally noticed at IBM that the build process used to heavily relay on connection to server and done something with it.
With new designer You don't event have to replicate to local. You can directly work on Your local server.

Why i'm i not able start noir server in intelli idea ID..?

I'm totally new to clojure... here is what I do
(use 'Yuhuru.server) // works fine, i mean gives nil
(def mysrv (noir.server/start 8080)) //now it gives
failed Server#9bfee2: java.net.SocketException: Unrecognized Windows
Sockets error: 10106: create java.net.SocketException: Unrecognized
Windows Sockets error: 10106: create (NO_SOURCE_FILE:2)
but using commandline i'm able start server.. is there any setting i'm missing in ID.. Please throw some light..
Thanks in advance
Problems with IntelliJ REPL not being able to create sockets under Windows used to come from the system environment variables not being propagated to the child JVM REPL process. Without these Windows won't be able to create a socket.
To test if your IntelliJ suffers from this problem, do a (System/getenv) from the REPL in IntelliJ and you'll see you get an empty map, instead of a map filled with your system variables like you get with a REPL from the commandline.
This is a recurring issue in various versions of IntelliJ/LaClojure. It was fixed in an earlier IntelliJ 10 / LaClojure version (0.3.92), but the last LaClojure update for IntelliJ 10 (0.3.102) broke it again.
I verified it should be fixed in the current IntelliJ idea 11.0.2 #IC-111.277 with LaClojure 0.4.30 combination. Downgrading LaClojure to 0.3.92 should work as well if you have to keep IntelliJ 10.
Sounds something like this: https://forums.oracle.com/forums/thread.jspa?messageID=9457989
Go here: http://plugins.intellij.net/plugin/?idea&id=4050 ; scroll down to the comments at 2010-06-08 20:39:35, it sounds like an issue with LaClojure (I'm assuming that you're using that...)

Ejabberd module with child process

I created a logging module which logs messages to a mysql db, the current code is located here:
https://github.com/amiadogroup/mod_log_chat_mysql5/blob/master/src/mod_log_chat_mysql5.erl
The Problem with the current code is, that sometimes the connection gets closed and as a result, the module doesn't work anymore.
As you see in the code, I store the DBRef in an ets table, which is not really the good way to go.
I asked the erlang mailinglist about this and they suggested me to do the DB Connection as an own child process of the module. This would enable the module to gracefully restart the connection upon closing of the connection.
Now my question is: how can I implement this child process with gen_server and/or gen_mod?
Do I need to create two files or can I do it within the same file?
Is there any example somewhere on how I could achieve that?
Edit: As you can see in the linked github repo, I updated the code and it works now, weeha!
Looking at the mod_Archive code helped me a lot, although I didn't decide to upgrade my ejabberd version.
I ran into another, but related problem now. In the code you see that I do an initial query with "SET NAMES UTF8" to prevent garbling of messages. It seems that this isn't done again if the gen_server does a reconnect. Is there any hook I can call upon reconnect so that the UTF8 query is done everytime?
Edit#2:
Now I switched to Emysql (https://github.com/Eonblast/Emysql) and it works out of the box by specifying the encoding directly on connect.
Code is on github.
Thanks for your help,
Michael
I suggest you look into general Erlang/OTP principles (gen_server, supervisor, etc).
ejabberd is relying on this standard Erlang architecture pattern.
Regarding your comment on database, ejabberd has its own way on managing database and passing queries to MySQL for example. You should as well look into it.
In your source code you are only applying the gen_mod behaviour, if you do wish to have a gen_server you can do it in the same module, if you define the gen_server behaviour has well.
A good example would be the ejabberd module mod_archive, which implements both behaviours.
Edit: I never really worked "directly" with mysql on erlang. But through the ejabberd methods I find it pretty "easy"(you will have to make a few setup, but rather easy). You have the method
ejabberd_odbc:sql_query_t(Query)
And has an example you can find it on the module mod_archive_odbc.
To use that method(and the last module) I haved downloaded the mysql native driver and put the beams created from the driver in ejabberd ebin dir (you can put it anywhere has long is on the erlang path).
A a soft link to the ejabberd ebin is my favorite:
ln -s <diryouhavethedriver>/ebin/*.beam /usr/lib/ejabberd/ebin/
and do a few configurations on you ejabberd.cfg. This process is described on this page on process one. Notice that the full steps are to make mysql the full database of ejabberd. You may not want that, so you must jump a few steps.
Hope this help.