Skip to main content

Posts

Showing posts from 2012

Authenticate OpenXava users with ActiveDirectory

The following allows you to use JNDIRealm 's LDAP authentication to authenticate users of OpenXava application with Active Directory. The users will be prompt to enter their windows credentials, when entering the usernames they need to avoid entering the domain name; they just need to enter the username. If you have multiple Active Directory domains to authenticate against, you can use  org.apache.catalina.realm.CombinedRealm to allow Tomcat to search on both. In the web.xml you will need to specify the security-constraint setting. This will force the user to authenticate when they reach any OpenXava module. in role-name, you have to enter the Windows Group name of that is allow to access the application. If you need finer restrictions, you can use OpenXava's Users.getCurrent() to get the username of the current user in your Java code. For example, you could have a validation logic to prevent a certain user from creating a new record. Please note that you must use a ...

A Solution to the Marriage Dilemma

In the midst of the raging battle between those who want to legalize homosexual marriages and those who oppose it, a solution could be implemented that would fit the goals of both sides. The problem with the traditional marriage constitutional amendment is that it asks the Government for the wrong thing. Asking the Government to define marriage as one man and one woman is a huge mistake because it takes away that power from religion and puts that power in a Government that is already taking too much power. It is extremely important for the survival of the Church that the government stays away from her . If we let the Government take that power,  not only would break the first amendment, but it also would teach future Christians generations that it does not matter what the Bible says what marriage is, all it matters is what the Government says it is. The definition of marriage belongs to culture and religion and it should stay there.  Instead, I would like to propose the...

Construct2: surpassing GameMaker and Multimedia Fusion

I a few years ago, I posted an article about why I preferred GameMaker over Multimedia Fusion. A lot has happened since then, Clickteam released many exporters for MMF (Flash, IOS and others) and YoYo Games have made HTML5 gaming GameMaker’s new target. Another product has been in the works too, Scirra produced Construct2 as a HTML5 game maker. Just like I reached my conclusion back then through spending time on GameMaker, I have come to the conclusion that Scirra’s Construct2 is a very worthy contender to both by spending some time using it and writing plugins for it. Construct2’s main target is HTML5 gaming, however, it is straight forward to create exporters for it and I am actually working on a XNA exporter for it. I have also created plugins that allow Construct2 games to create simple 3D games (WebGL via Copperlicht), online multiplayer games (through websockets) and isometric games (through a Z sorter plugin).   Construct2 enjoys an easy-to-use event-driven inter...

How to create online multiplayer HTML5 games in Contruct2

  Construct2 can use websockets to send and receive messages between games. By using socket-io , we can use a Node.js script as the server and my modification to the socket-io plugin for Construct2 to allow the games to synchronize data between them in real-time. There are two parts to this design: the Node.js server and the Construct2 clients (the games playing). The main part of building an online multiplayer HTML5 game is to plan: how the clients will communicate how often and what to communicate how much of the logic will go into the server and how much to the client. In my sample game, I chose to have each client own a player and have the server just relay messages: Use string messages in the form TypeOfMessage, Parameter1, Paremeter2, Parater3, etc to communicate. Have the clients send their player position about 16 times a second. Whenever their player shoots, the client needs to send a message immediately. Almost all of the game logic will...

Prevent Visual Studio from using SQLEXPRESS when using Webparts

To prevent Visual Studio from using SQLEXPRESS when using Webparts and WebPartManger, you will need to override the "LocalSqlServer" connection string from your machine.config into your web.config file. To do that, add the following to the <connectionstrings> sections in your webconfig file: <remove name="LocalSqlServer"> <add connectionstring="data source=.\YOURINSTANCENAME;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" name="LocalSqlServer" providername="System.Data.SqlClient"> </add> Othwerise, if you do not have an instance named SQLEXPRESS in your machine, the page containing your WebPartManager will fail with the following error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is co...

Using GAE OData from C#: Authentication

The last post about ODATA in the Google App Engine (python) allowed anyone to create, update or delete the models. Google App Engine (GAE) can authenticate Google users or users of you Google Apps domain. Using this feature, we can authenticate users of our C# application and use the authentication token when submitting calls to our OData service. The following class is based on the work found in  here . class GAEAuthentication { public string Authenticate(string gaeAppBaseUrl, string googleUserName, String googlePassword, string yourClientApp, string is_admin, bool is_dev_env) { string googleCookie; String gaeAppLoginUrl = gaeAppBaseUrl + "_ah/login"; String yourGaeAuthUrl = gaeAppBaseUrl + "odata.svc/"; String googleLoginUrl; if (is_dev_env) { googleLoginUrl = gaeAppLoginUrl; } else { ...
I am working on a plugin for Scirra's Construct2 that would allow users to present their C2 levels as 3D levels in copperlicht. Here is a demo so far: http://mathbattlegame.appspot.com/static/copperlicht/tutorial2/index.html I synchronize the positions and rotations between C2 and copperlicht, so copperlicht is just a "screen" for C2's logic. In the demo you see that you actually move and rotate the C2 sprite, and copperlicht is just being told to imitate the pos and rotation. This will allow you to use all the nice things from C2 and show them in 3D. You move by using the arrow keys and you can shoot "bullets" by pressing 'Q'.  I added the download to both the plugin and the demo at: https://sites.google.com/site/jptarqu/downloads  The name of the download is  copperlicht-c2-plugin-v-0.9.zip .  Please note that to run the sample capx, you will need to export it to your web server (either local server like IIS express, apache, etc. or to a external...

Uh???

I am so confused with the Ms. Fluke situation, I have no clue what is going on. Limbaugh says she is asking taxpayers to pay for her contraceptives; but then I read that she (as a customer) was actually asking her private insurance to cover them and not the Government, which is her right as a customer to ask from a private company. But the, if it is a private business issue, I don't understand why is the Federal Government getting involved? Then I also read that most private insurance cover Viagra, is this why medical bills are so expensive? is it because Insurers can't pay for them because the insurance pool money is being used to pay for Viagra pills? I also read that this all started when the federal government added the free-contraceptives requirement to insurance carries as part of the Universal health care plan. I still remember during the health care debate a few years ago, Hillary Clinton was asked how the plan was going to protect itself from bankruptcy by the peop...

Using GAE as a OData service for the data layer

One of the many challenges of software development is to allow your application to save its data into a reliable repository from anywhere in the world. With Google App Engine ( GAE ) and its cloud service, you can put the data layer of your application in the cloud and still use your preferred programming language to create your business and presentation layers. By exposing your GAE database using OData ( http://www.odata.org/ ), you get a flexible way of storing and retrieving your data from any desktop client or mobile application including C# based applications. The best thing is that GAE offers free quotas unlike Microsoft Azure's offerings. One OData library that I know works in GAE is odata-py (  http://code.google.com/p/odata-py/ ). After downloading the latest version (using SVN), you can start using the sample GAE application that comes with it. There is however, one small fix you need to make. Modify core.py to prevent an exception when getting the Key from the url when...

Convert PDF files to TIFF using power shell

You can use the following ps script to convert PDF files into TIFF files: $tool = 'C:\Program Files\gs\gs9.01\bin\gswin64c.exe' #the path to your Ghostscript program. $files_folder = 'c:\youfolderwithpdfs' $pdfs = get-childitem $files_folder -recurse | where {$_.Extension -match "pdf"} foreach($pdf in $pdfs) {     $tiff = $pdf.FullName.replace('.pdf','').replace('.pdf','') + '_-_p%03d.tiff'     if(test-path $tiff)     {         "tiff file already exists " + $tiff     }     else             {            'Processing ' + $pdf.Name                 $param = "-sOutputFile=$tiff"         & $tool -q -dNOPAUSE -sDEVICE=tiffg4 $param $pdf.FullName -c quit     } } The script creates one Tiff file per PDF page. There are other options inGhostscript that you can use. To get Ghostscript for wi...

There is already an open DataReader error and how to fix it

When trying to execute SaveChanges on a Entitiy Framework datacontext, I was getting the following error: There is already an open DataReader associated with this Command which must be closed first The problem was caused by the location of the SaveChanges call. The code called the method inside a ForEach loop that iterates through a result returned from a query. Because of the iteration the datacontext’s connection was on read mode and thus did not allow me to call the update. To fix it I moved the SaveChanges call outside the ForEach loop (when the read was completed: var records = EFDataRepository.GetAll ().Where(r => r.CreatedOn < cutoff_date); foreach (var record in records) { workflow.WorkAndUpdate(record); //repo.SaveChanges(); //do not put it here, you are still iterating over the results in read mode } repo.SaveChanges();