Twitter Bootstrap Single Page App with Node.JS

This is Part 1 of a 3 part series on a single page application for Node.JS. I love Twitter Bootstrap. Yes, there are several similar frameworks, but I like the fact that Bootstrap works on nearly all modern browsers (Firefox, Chrome, Safari (Stinkin) IE 8+). Although Twitter Bootstrap was not initially great for Mobile apps, they have done some recent updates that provide near compatibility on mobile devices like iPad, iPhone and Android. I started this project as a boilerplate for single-page apps, and later realized that it’s a good backend for Bootstrap. There are several great Bootstrap mods, themes … Continue reading Twitter Bootstrap Single Page App with Node.JS

Cross Domain (External) Ajax calls with JQuery / Javascript

Originally posted on Do you need to use this code :
Issues 1. As of jQuery 1.5, the success callback function receives a “jqXHR” object (in jQuery 1.4, it received the XMLHttpRequest object). However, since JSONP and cross-domain GET requests do not use XHR, in those cases the jqXHR and textStatus parameters passed to the success callback are undefined. 2. Cross-domain requests are inherently insecure. Either you are sending credentials over clear text, OR, you cannot make cross-domain requests (not without an ugly client side warning atleast) on HTTPS. Solution jQuery 1.5, there has been a new property added to $.ajax.… Continue reading Cross Domain (External) Ajax calls with JQuery / Javascript

Find the right side (value) of expression in Java.

A simple example using RegEx: import java.util.regex.Matcher; import java.util.regex.Pattern; Pattern pattern = Pattern.compile(“[\\d\\w\\s’\”]+\\z”); Matcher matcher = pattern.matcher(“value=\”hello my name is bob\””); while (matcher.find()) { System.out.print(“found:'””‘”); } prints… found:’”hello my name is bob”‘ This will work for strings containing apostrophes and quotes too. Any quotes (“) must first be escaped with a \ in the search string. Continue reading Find the right side (value) of expression in Java.

JSON Serializers on C# / .NET – Late 2011

JSON has been around for a while now, and it’s appeal is still growing in the interest of things like REST services and the NoSQL (A.K.A Document) database movement (FYI – I’m much more fond of the NoSQL movement than the Occupy movement). But, yet, it still seems that a good JSON serializer is hard to come by. I’m in the habit of making my apps simply aware of an ISerializer so that I can choose to implement the JSON-serializer-of the-day. I have toyed with a few JSON serializers: Json.NET JayRock DataContractJsonSerializer JSONSharp LitJSON JavaScriptSerializer They’re all sort of <OK>, … Continue reading JSON Serializers on C# / .NET – Late 2011

Hibernate and Postgres – a custom UserType to handle arrays

Here is a custom Hibernate UserType that will work to persist Java array types (string[], int[], boolean[], etc..) in a single column. I have seen Oracle implementations, but here is one that uses Java.sql.array and works for Postgres. If you’d like to know more about how this works, Andrew Phillips has written a great explanation of custom Hibernate UserTypes. Enjoy! _______________________ import; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.sql.Array; import org.hibernate.*; import org.hibernate.usertype.UserType; /* * Custom UserType implemented to store java array (ie; String[]) types */ public class CustomArrayType implements UserType { public int[] sqlTypes() { … Continue reading Hibernate and Postgres – a custom UserType to handle arrays

RegEx Pattern (Java) for Finding or Matching Operators

Here is a regular expression pattern that can be used to find the operator in a SQL expression. For that matter any F=V type expression. Given a “field (operator) value” expression, this regex pattern will match and find the operator portion in strings such as… field = value, field > value, field >=, field <= value, field value, etc.. Pattern: [=\\]*[^a-zA-Z0-9] Note – The above pattern worked for Java 1.6, and on other languages it maybe possible to remove so of the escape slashes in the “[=\\]” portion to “[=]”. If you would like to find other RegEx patterns, I … Continue reading RegEx Pattern (Java) for Finding or Matching Operators