I have a web app that serves some markdown files. What i would like to do is when there is a push to github i would ping my application using a webhook and i want my application to run git pull to retrieve changes. I am sure that no application specific files will change only markdown files in a specific folder.
Does any one done something like this?
Do you see any long term problems with this approach?
Here's how to do it in Clojure (since you have a Clojure-tag on your question): http://infolace.blogspot.com/2009/08/simple-webhooks-with-clojure-and-ring.html
http://www.kernel.org/pub/software/scm/git/docs/githooks.html
post-receive
Write a small script that will alert your java program somehow. Or even do the git pull in the script?
Related
I have written an android application. I would like to be able to customize the app programmatically. For example, change logos/titles within the application.
Assume I have a simple web server that displays a form with fields to input text, upload images etc. Upon submission of this form, I would like to generate an apk file available for download for the user.
Is there a way to script eclipse to achieve this? Is that even where I should be looking? If anyone has done something like this, (or have some ideas), please let me know!
Thanks
Is there a way to script eclipse to achieve this?
Possibly, but I doubt it.
Is that even where I should be looking?
Use Ant. Make a copy of some master project, make your adjustments from the entered data, and run the appropriate ant tasks (e.g., ant release build) to create the APK.
We have put together a system that creates multiple, customised APKs from a single body of source code. The system is not in a state where we can make it available (although we may open source it at some point) but the general structure is described here.
Having said that, the system you describe in your question is much more dynamic than what we need. We only need to create a few (~10) different variants. It strikes me that what you're trying to do would be better solved by having a single APK together with a configuration file. Your webserver would generate the configuration file, not the APK.
I want to build an Android application that downloads an XML file from a web server and displays its contents in a readable format.
My problem is generating that XML file. Basically I want to run a program, say, every 30 minutes that downloads a web page (as that data is not easily accessible), parses it, generates said XML file and puts it somewhere for the Android application to download.
Now, I was writing a Java application to do this, but it came to me: where am I going to run this? I thought of having a laptop permanently running at home, but there must be a better alternative.
I have online hosting, but it is very simple. It does not even include SSH.
Any ideas?
Edit: as per your suggestions, I checked and yes, my cPanel does have a "Cron Jobs" section. I will now investigate it. Thank you so much for your help.
http://www.setcronjob.com/ allows you to trigger a web page request once every hour, which might be good enough.
I have not actually tried it, but it sounds like a good solution.
you need to rent a server which will generate your html and also serve the content to your app. Not expensive if you get a VPS or cloud server.
I have finished writing a Java Desktop application with a mySQL database. I want to make the application run outside netbeans and let it be installed on other computers. I know about building the project and creating the runnable jar file, however this requires me to export the database itself to the other computer I want the application to run on.
My question is two parts:
1)Is there a way I can create a setup file that also installs the database and the application together?
2)Also my database path is hard coded, does that mean I have to change the code every time I install my application for someone, what is the better way to do that?
Thanks
Yes. You can use some setup builder, like InnoSetup, for example. Personally, however, I like giving my customers a zip file, which they extract wherever they like. The executable jar should be able to handle everything by itself (I like it where there is no need to install the software, just unpack and run).
If it is hardcoded, then yes (but, what do you mean by hardcoded? path to file? ip address?). You should use properties or configuration files for paths and other external things your software depends on. The software should read from those files. Upon startup check for presence of such file(s) - if missing, the user should be shown a window in which the config can be entered.
As for deploying MySQL with your code - consider using a server for that, so that your users are not forced to install MySQL, instead they connect to it over the net. If you need the database only for storing data locally, why not using SQLite or a similar, file-based db engine?
The above answers are just suggestions and more-less reflect the way I am thinking. I would be happy to hear from someone with more experience. Nonetheless, I hope the answers help a little :)
I agree with Sorrow.
If I have to use MySQL, it is normally over the net since I don't want to allow my clients pass through the hazzles of installing MySQL themselves. If however you am stuck with using MySQL locally, investigate MySQL unattended installations + NSIS Installer.
If you can use any db you want, I just use javadb/derby. It comes bundled with most Java installations these days and if not all you need is to add a jar file to you application.
As per 'hardcoding' paths, I really don't understand what you mean. You really don't have 'paths' as it were, I am assuming what you mean is connection string. You don't have to hardcode your connection string, just put some parameters in a properties file and construct your connection string from them.
1) Is there a way I can create a setup file that also installs the database and the application together?
See my answer to Java based Standalone application.
2) Also my database path is hard coded, does that mean I have to change the code every time I install my application for someone, what is the better way to do that?
Have the DB installer pop a JFileChooser to ask the user where they want to install the DB. Store that path using the JNLP API PersistenceService. Here is my demo. of the PersistenceService.
So I'm working on a project where I would like to be able to have the user browse the Active Directory to find a machine or workstation. I already know that you can envoke this directory search in the command prompt by using:
rundll32 dsquery,OpenQueryWindow
I'm using java for my project and I understand how to capture input from a command that I execute in the program but currently, at home, I'm not connected to a domain so I cannot test what the command returns when a user selects a computer or if it even returns anything. Could someone test this for me and tell me what it returns.
Also, if anyone has any better ideas on how to achieve this without relying on window's tools, like maybe a Java API for Active Directory Services?
Instead of calling an API function using rundll32, you should use a Java based LDAP library which will encapsulate the work in front of the Active Directory (so you won't have to parse the results by yourself).
Also, if anyone has any better ideas on how to achieve this without relying on window's tools, like maybe a Java API for Active Directory Services?
Choosing a pure Java library could help you run your application on many platforms (as opposed to using Windows' rundll32 which will limit you to Windows platform)
Check out this thread: https://stackoverflow.com/questions/389746/ldap-java-library.
currently, at home, I'm not connected to a domain so I cannot test what the command returns
There are solutions for this kind of testing problems. You should read about mocking: http://en.wikipedia.org/wiki/Mock_object
Good luck!
Tal.
Talk to the AD via the LDAP API.
I'm trying to create a web application which will get input from system.
What this application should do is to listen what happens when some shell scripts are executing and reporting the status trough web.
An example :
I'm copying thousands of records with shell script, and while this is still executing I'd like pass the current status of the script to the web interface. From shell script side I could echo something like "The files are being copied please wait for it to finnish".
Using which programming language from shell side would be the easiest way to pass this to the web interface? I intended to use JSP/JAVA for web.
Is this even the right way to think about this? Every suggestion is welcome
EDIT
Would something like http://nodejs.org/ be useful for this?
I'd use a named pipe (FIFO) instead. You simply write your output to the pipe and let the application read it. I'm not sure if there is any other way to get a more live system than this.
I'd recommend Perl as the back-end.
EDIT:
named pipes are a special type of files on UNIX. The abbreviation FIFO stands for "First In First Out". On LINUX Journal you can find an interesting read about named pipes.
Perl is a very powerful scripting language with many ready-to-use modules which you can find on http://cpan.org. You can find some answers here on SO about how/where to start learning Perl.
The Web part of your application can easily read a file or a database, so you just need to make sure that your shell scripts are outputting something for your Java code to update.
For example, if you run your shell script like this
./myscript.sh > mylog.log
Then in your Java code (note that you should not have logic in your JSP), you can read in the file to determine the status of the update, and output the result to your JSP.
It would be better to read the data in from a database, but that would involve you changing your shell script to output the data to a database.
You could put shell script output to some storage on server. And use AJAX on the web page to poll the server and get updates from that storage to the page.
If you will decide to use JSF for web page creation I can recommend "a4j:poll" component from ajax2jsf library. It is very simple and straightforward. Very easy way to poll server from the web page.
Writing to log file would be the simplest solution. And in programming, simple often means good.
If you really need very fast/realtime system, you should probably make these logs a database.
As for language, use what you like best. They all do support SQLite, including bash.
If I understand your question correctly you want to display a web page on a client machine that reports the status of a long running task on a server machine. If that is the case then you need to focus on something called AJAX IMO.
For what it is worth the simplest and easiest to understand implementation of AJAX that I know of is Apache Wicket.