Counterclockwise HTTP REPL - eclipse

In Eclipse+Counterclockwise, when I want to connect to REPL, the dialog tells me I can use nREPL over HTTP:
How to set this up? Is this somehow connected to drawbridge? I haven't been able to make these work together, although lein repl :connect http://my.url/repl worked for me.
For clarity, why this is useful compared to classic REPL: classic REPL works for localhost only. You can bridge it through SSH port tunnelling, but this - REPL over HTTP - is a viable alternative for remote, "live" servers.
Just for completeness, the server side:
drawbridge - the HTTP transport - https://github.com/cemerick/drawbridge
how to use it - https://devcenter.heroku.com/articles/debugging-clojure
example app - https://github.com/technomancy/chortles

I've just installed CCW and tried against https://github.com/technomancy/chortles: I did "lein run" after exporting the environment variables suggested there and it connects to http://flynn:reindeerflotilla#localhost:5000/repl like a charm. I tried to evaluate simple expressions and I had no problems at all while the server was up&running. I'm using Leiningen 2.4.3 to run it.
Chortle's sources https://github.com/technomancy/chortles/blob/master/src/chortles/web.clj seem to be quite simple, the main handler is wrapped in drawbridge middleware including session and parameters support too. Does that work for you? Is it feasible to use the same approach for your own application?

Related

How to run Identity Server V3 client examples

I'm trying to run some of the examples from here. They're configured to access localhost:44333 - if I run one of the examples, e.g. JavascriptResourceOwner, the calls to that address are not getting any response. What project/solution should I be running on that port?
You should run IdentityServer in separate solution for example from example
IdentityServer3.AspNetIdentity
All client samples are designed to be run with the core project host:
https://github.com/IdentityServer/IdentityServer3

Clojure coding with Emacs and Cider

I am new to Clojure coding and went through a number of articles to set up Emacs for development.
The setup itself works as designed, but I have been running server from Cider session and killing Emacs entirely when making any code change. Or, I need to find the server process from shell session, and kill it from there. This is far from ideal.
clojure-getting-started/web.clj
(defn -main [& [port]]
(let [port (Integer. (or port (env :port) 5000))]
(jetty/run-jetty (site #'app) {:port port :join? false})))
Cider session
clojure-getting-started.web> (defonce server (-main))
After starting the server, I will get the below error with (server) function:
1. Unhandled java.lang.ClassCastException
org.eclipse.jetty.server.Server cannot be cast to clojure.lang.IFn
The error message makes sense, but how can I refresh my code base using just Emacs?
I suppose (and hope) there is a better way than starting shell session on Emacs and kill the process there...
Assuming what you are wanting is to run a jetty server and have it load or reload your code when you change it from within emacs. While the advice already given is good, it may be more complex than you need when getting started. My advice is to take advantage of some of the templates out there for lein which will setup a default environment and workflow for you to begin with. You can then refine this default as you learn more until you get the workflow which suits you. My recommendation would be to start witht the default compojure template i.e.
lein new compojure my-project
This creates a bare bones project with the basic ring and compojure libraries and lein plugins as well as a simple dev profile.
Edit the src/my_project/handler.clj file and add the ring.middleware.reload middleware e.g.
(ns my-project.handler
(:require [compojure.core :refer :all]
[compojure.route :as route]
[ring.middleware.reload :refer [wrap-reload]]
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]))
(defroutes app-routes
(GET "/" [] "Hello World")
(route/not-found "Not Found"))
(def app
(-> app-routes
wrap-reload
(wrap-defaults site-defaults)))
The wrap-reload middleware will cause your code to be reloaded when it is modified. You won't need to restart the jetty server for your code changes to take effect - just reload the page.
In a terminal run either
lein ring server
or
lein ring server-headless
This will start a jetty server listening on port 3000. Then from within emacs, you can just open a cider repl to use while writing your code. You won't need to restart the server process unless you make changes to your project.clj file. Same with the cider process.
Then, once your comfortable with this, look at the lein-ring documentation. There you will find information on how to setup a repl.clj file within the project. Once you do that, you will be able to do something like
lein repl
and then from within that repl, do something like
(start-server)
which will start the server. You can then switch to emacs and instead of running cider-jack-in, you can do a cider-connect, which will connect tot he already running repl rather than starting a second repl session. Later, if you decide to start also looking at clojurescript, you can look at some of the default templates for clojure+clojurescript apps. I quite like figwheel and use reagent a fair bit, so I also find the reagent template quite good.
There are quite a few lein templates out there and I find it really useful to just run them and have a look at what they do. I then tend to cherry pick the features/options I like.
Here's most of the answer I just gave to a similar question:
Try the (refresh) function in the clojure.tools.namespace.repl namespace:
The refresh function will scan all the directories on the classpath for Clojure source files, read their ns declarations, build a graph of their dependencies, and load them in dependency order.
https://github.com/clojure/tools.namespace#reloading-code-usage
We generally add that plus a few other useful things to the user namespace, so it's loaded into the REPL on startup:
(ns user
(:require [clojure.tools.namespace.repl :refer [refresh]]
[clojure.repl :refer [doc source]]
[clojure.pprint :refer [pprint pp]]
[midje.repl :as midje]
[clojure.stacktrace :as st]))
To keep that code separate from your main and test sources, put that in a file at <project root>/dev/user.clj, then add the following to your lein project.clj file:
:profiles {:dev {:source-paths ["dev"]}}
Concerning the ClassCastException - server needs to be a function of 1 param:
(defonce server (fn [request] (-main)))

How to pass data by host page when using golang as gwt 's backend?

Currently,my configuration is like this:
gwt+nginx+golang
,and nginx works as a proxy that will redirect all requests(on port:80) to golang server(on port:8080).Since I use golang as backend,so I want user to access my website by
www.domain.com
directly without specifing host page like this:
www.domain.com/index.html.
I think it should be easy in production model:just proxy all requests on / to a golang service,question is on development model:without a host page,How to get gwt app run up?
DevMode is no different actually. Deploy a compiled version on your server once, then run DevMode in -noserver mode passing it -startupUrl http://www.domain.com. It should Just Work™.

Stop framework from using HTTP Proxy

After nearly drowning in tears of frustration I have to ask you a question.
My play (2.0.3, scala) application is consuming a wsdl, which works perfectly fine, if I run the dev version of my webservice on localhost, which makes the wsdl-url something like http://localhost:8080/Service/Service?wsdl.
When I try to consume the WSDl from the remote test system server, with an Url like http://testserver.company.net:8084/Service/Service?wsdl, I get:
[WebServiceException: Failed to access the WSDL at: http://testserver.company.net:8084/Service/Service?wsdl. It failed with: Got Server returned HTTP response code: 502 for URL: http://testserver.company.net:8084/Service/Service?wsdl while opening stream from http://testserver.company.net:8084/Service/Service?wsdl.]
My company uses a http proxy for internet use, which is the reason for the 502 error. So I want play to stop using the proxy.
So far I have tried (all together):
deleted proxy from Intenet Explorer
set _JAVA_OPTIONS=-Dhttp.noProxyHosts="testserver.company.net"
set JAVA_OPTIONS=-Dhttp.noProxyHosts="testserver.company.net"
play run -Dhttp.noProxyHosts="testserver.company.net"
None of this worked. Any ideas? How can I stop play from using the HttpProxy?
EDIT:
I found it has someting to do with java Webservices-api / jaxws libraries.
Any ideas?
EDIT 2012-10-17:
It seams to depend on system proxy settings. I still don't know why it didn't work that day although I deleted the whole proxy from IE and restarted everything. Is there any way to make my play app independend from system settings?
Try:
play -Dhttp.noProxyHosts="testserver.company.net" run
I noticed a typo in your property, the correct property is http.nonProxyHosts so add and extra n after no.

ASP.Net MVC 2 on nginx/mono 2.8

I am trying to setup ASP.Net MVC 2 application on Linux environment. I've installed Ubuntu 10.10 on VirtualBox, then installed Mono 2.8 from sources. After that I have installed nginx and configure it as recommended here.
Unfortunately, FastCGI shows me standard error 500 page:
No Application Found
Unable to find a matching application for request:
Host localhost:80
Port 80
Request Path /Default.aspx
Physical Path /var/www/mvc/Default.aspx
My application is located in /var/www/mvc directory. I've tried to create some stub Default.aspx file and place it in root dir of my application, but it didn't help, same error occured.
Thanks.
I've been doing some testing with this as well, using all ubuntu10.10 binaries.
From what I can make from it, either nginx fails to pass the hostname of the mono server fails to receive it over the fastcgi protocol. Anyhow, the tutorial line:
fastcgi-mono-server2 /applications=www.domain1.xyz:/:/var/www/www.domain1.xyz/ /socket=tcp:127.0.0.1:9000
doesn't work. Removing the hostname makes the thing work:
fastcgi-mono-server2 /applications=/:/var/www/www.domain1.xyz/ /socket=tcp:127.0.0.1:9000
but this of course blocks the use of multiple virtual mono hosts.
Since you are running ASP.NET MVC 2 application you should use fastcgi-mono-server4.
Adding following line in /etc/nginx/fastcgi_param resolves the issue for me. It also allows to use multiple virtual hosts.
fastcgi_param HTTP_HOST $host;
Does your application work with xsp (xsp4 if you are using .net 4.0)? You'll want to make sure that is working before you try configuring the connection to another web server.
Does nginx know where to find mono? You most likely have a parallel install and it won't be in the default paths.
I use apache, but you may still find some of the instructions on my blog useful:
http://tqcblog.com/2010/04/02/ubuntu-subversion-teamcity-mono-2-6-and-asp-net-mvc/
I had this problem just now, I too had been following the document on the mono site:
I was trying to start the fastcgi-mono-server as it suggested:
sudo fastcgi-mono-server4 /applications=www.domain1.xyz:/:/var/www/www.domain1.xyz/ /socket=tcp:127.0.0.1:9000 &
However when I did it like that I got the same problem as you. I changed it to this:
sudo fastcgi-mono-server4 /applications=/:/var/www/www.domain1.xyz/ /socket=tcp:127.0.0.1:9000 &
And it worked ( I had to type in www.domain1.xyz/Home/Index to see my MVC page, not worked out how to stop it looking for www.domain1.xyz/default.aspx yet XD ).
You need to make sure the domain set in your site config matches the domain passed to the fastcgi server. So for example if your default site (/etc/nginx/sites-enabled/default) has the following config:
server {
...
server_name www.domain1.xyz;
...
}
You would need to pass that domain into the fastcgi server:
sudo fastcgi-mono-server4 /applications=www.domain1.xyz:/:/var/www/www.domain1.xyz/ ...
Then when you access the site it will obviously need to be with that domain you set.