Tuesday, July 23, 2013

BackboneJS: click event is being triggered twice

In the view definition I had:

...
...
 // events
    ,events: {
        'click ': 'selectServiceEvent',
        'click a': 'learnMoreLinkEvent'
    }
...
...
,selectServiceEvent: function () {
        this.clickCard(); 
}

But when I was clicking the div generated by de view, the selectServiceEvent function was being triggered twice. The solution was add return false; to the selectServiceEvent function:

,selectServiceEvent: function () {
        this.clickCard(); 
        return false;
}

Monday, July 22, 2013

Google Chrome and WOFF font MIME type warnings

There is a link that explains the situation about the Google Chrome and WOFF font MIME type warnings:

 http://zduck.com/2013/google-chrome-and-woff-font-mime-type-warnings/

IIS7: Resource interpreted as Font but transferred with MIME type application/octet-stream:

With a site hosted in IIS I was getting this warning:

Resource interpreted as Font but transferred with MIME type application/octet-stream: "http://localhost/Website/assets/webfonts/mplus-1c-light-webfont.ttf". index.html:6
Resource interpreted as Font but transferred with MIME type application/octet-stream: "http://localhost/Website/assets/webfonts/mplus-1c-regular-webfont.ttf". index.html:6

The solution is:

1. Open IIS manager
2. Go to MIME types
3. Click on "add..."
4. Fill the fields:
   - File name extension: .woff
   - MIME Type: application/x-font-woff
5. Restart IIS.

References:
http://stackoverflow.com/questions/15521130/google-warning-resource-interpreted-as-font-but-transferred-with-mime-type-appl
http://stackoverflow.com/questions/3594823/mime-type-for-woff-fonts

JQuery: simple slider form

Here is a great and simple sample that shows a form using sliders without using any slider lib, just jquery and jqueryui:

http://webexpedition18.com/articles/how-to-create-a-multi-step-signup-form-with-css3-and-jquery/

Wednesday, July 3, 2013

LINQ: filter by two fields concatenation

When you hava an entiy with FirstName and LastName columns, and you need to filter by fullname, a quick solution is to filter by the fields value concatenation:

var agents = from a in DB.Agents
                                 where a.FirstName.Contains(name) ||
                                       a.LastName.Contains(name) ||
                                       String.Concat(a.FirstName, " ", a.LastName).Contains(name)
                                 select a;



Thursday, June 27, 2013

JPQL: parameter using LIKE clause

Example named query:

    @NamedQuery(
        name = "BismarkPlan.findBismarkPlanByClientIdAndBismarkPlanNameOrBismarkPlanCode"
        ,query  = "SELECT bp FROM BismarkPlan bp"
                    + ", BusinessProposalFormalization bpf"
                    + ", BusinessProposalFormalizationItem bpfi"        
                + " WHERE bpfi.businessProposalFormalizationId = bpf.id"
                    + " AND bpfi.bismarkPlanId = bp.id"
                    + " AND bpf.clientId =:clientId"
                    + " AND (bp.code LIKE :code OR bp.name LIKE :name)"
    )

then calling the query:

Long clientId = 2;
String bismarkPlanCode = "PB";
String bismarkPlanName = "Plan";
        
// TODO: use JPA querybuilder instead of namedqueries
Query query = em.createNamedQuery("BismarkPlan.findBismarkPlanByClientIdAndBismarkPlanNameOrBismarkPlanCode");
query.setParameter("clientId", clientId);
query.setParameter("code", "%" + bismarkPlanCode + "%");
query.setParameter("name", "%" + bismarkPlanName + "%");
List<BismarkPlan> returnList = query.getResultList();

Resource:
http://stackoverflow.com/questions/1341104/parameter-in-like-clause-jpql


XAMPP 1.8.1 Apache 2.4 AH00526: Syntax error ProxyPass worker name (...) too long. Bug

I was getting this error:

AH00526: Syntax error on line 228 of E:/Documents/Dropbox/Programs/windows7/xampp-win32-1.8.1-VC9/xampp/apache/conf/extr
a/httpd-proxy.conf:
ProxyPass worker name (http://localhost:8080/SIBismarkRestServer/webresources/com.expertix.bismark.si.entities.orderrequ
est/) too long

In this link https://issues.apache.org/bugzilla/show_bug.cgi?id=53218 Says that increasing in the mod_proxy.h file the PROXY_WORKER_MAX_NAME_SIZE value from 96 to a number that fits in your workername, ie

from
#define PROXY_WORKER_MAX_NAME_SIZE      96

to
#define PROXY_WORKER_MAX_NAME_SIZE      192

But I continue getting that error, no matter my url http://localhost:8080/SIBismarkRestServer/webresources/com.expertix.bismark.si.entities.orderrequ
est/ was 101 characters

So I had to make my url shorter