Wednesday, 11 September 2013

Spring security: A universal match pattern ('/**') is defined before other patterns in the filter chain, causing them to be ignored.

Spring security: A universal match pattern ('/**') is defined before other
patterns in the filter chain, causing them to be ignored.

I am trying to configure spring security on my simple app, but I keep
getting this error.
Caused by: java.lang.IllegalArgumentException: A universal match pattern
('/**') is defined before other patterns in the filter chain, causing
them to be ignored. Please check the ordering in your <security:http>
namespace or FilterChainProxy bean configuration
I have seen other similar posts, but could not figure out why I am getting
this error. I don't seems to have duplicate security:http namespace
configured.
Here goes my web.xml
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>sampler</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:**/sampler-context.xml
classpath:**/sampler-security.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>sampler</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>sampler</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
spring security config:
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<!-- Add Authentication Manager -->
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" authorities="ROLE_USER" password="test"/>
</user-service>
</authentication-provider>
</authentication-manager>
<!-- This would add login screen -->
<http auto-config="true">
<intercept-url pattern="/admin/*" access="ROLE_USER"/>
</http>
Its just a simple login functionality that I wanted to provide as of now.
Any help around this issue would be really appreciated.

Getting data from external server with JSONP

Getting data from external server with JSONP

Im trying to get some data from a web api on an external server. I can see
the right data under Network -> Response in Chrome debugger.
If i replace my url with a flicker JSON url i get a success. I can see in
the Response that the data is show differently, but i dont know how to
change my data to the same as flickr.
I made a Fiddle to demonstrate my problem: jsfiddle/8JDna/2/
<body>
<div id="content">
<div class="well">
</div>
</div>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</body>
$(function () {
var thisMonth = 0;
var flickrURL =
'http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?';
var myURL = 'http://driving.thylle.dk/api/distance?jsoncallback=?';
$.ajax({
url: myURL,
jsonp: "callback",
dataType: "jsonp",
data: {
format: "json"
},
success: function (data) {
$(".well").html("<h3> SUCCESS </h3>");
},
error: function (xhr, textStatus, errorThrown) {
$(".well" ).html("Error: " + textStatus + ": " + errorThrown);
},
});
});
I hope you can understand my question
Best regards Rasmus

Tuesday, 10 September 2013

Objective C - Multi line string using stringByAppendingFormat

Objective C - Multi line string using stringByAppendingFormat

I'm having an issue with the following code. I want the resultant
multiLineTitle to look like this
Each
Word
Should
Have
Its
Own
Line
But when I run this program, multiLineTitle ends up null. Can anyone spot
the issue?
NSString *title = "Each Word Should Have Its Own Line";
NSString *multiLineTitle;
NSArray *words = [title
componentsSeparatedByCharactersInSet:[NSCharacterSet
whitespaceCharacterSet]];
words = [words filteredArrayUsingPredicate:[NSPredicate
predicateWithFormat:@"SELF != ''"]];
for (int len = 0; len < [words count]; len++){
multiLineTitle = [multiLineTitle stringByAppendingFormat:@"%@ \n",
words[len]];
}

Associative arrays in oracle

Associative arrays in oracle

Associative Arrays as i understood it stores key value pairs and it is of
variable length. Like we can add number of key value pairs to Associative
array.
Also i read to use while loop to traverse sparese Associative array and
For loop to traverse Dense Associative array.
How can an associative array be sparse it is dynamic and we are adding
values to it

OpenCL (JOCL) - 2D calculus over two arrays in Kernel

OpenCL (JOCL) - 2D calculus over two arrays in Kernel

I'm asking this here because I thought I've understood how OpenCL works
but... I think there are several things I don't get.
What I want to do is to get the difference between all the values of two
arrays, then calculate the hypot and finally get the maximum hypot value,
so If I have:
double[] arrA = new double[]{1,2,3}
double[] arrB = new double[]{6,7,8}
Calculate
dx1 = 1 - 1; dx2 = 2 - 1; dx3 = 3 - 1, dx4= 1 - 2;... dxLast = 3 - 3
dy1 = 6 - 6; dy2 = 7 - 6; dy3 = 8 - 6, dy4= 6 - 7;... dyLast = 8 - 8
(Extreme dx and dy will get 0, but i don't care about ignoring those cases
by now)
Then calculate each hypot based on hypot(dx(i), dy(i)) And once all these
values where obtained, get the maximum hypot value
So, I have the next defined Kernel:
String programSource =
"#ifdef cl_khr_fp64 \n"
+ " #pragma OPENCL EXTENSION cl_khr_fp64 : enable \n"
+ "#elif defined(cl_amd_fp64) \n"
+ " #pragma OPENCL EXTENSION cl_amd_fp64 : enable \n"
+ "#else "
+ " #error Double precision floating point not supported by OpenCL
implementation.\n"
+ "

What is the algorithm class for identifying spelling errors without the use of a dictionary?

What is the algorithm class for identifying spelling errors without the
use of a dictionary?

Please consider the following situation: in a segment of text, there are
five occurrences of the string "slnFile", and one occurrence of "snlFile".
The latter is a misspelling, but note that the former word is not in a
proper dictionary ("slnFile" is a variable name indicating a "visual
studio solution file", making sense only to the author of the text
segment).
I can think of a simple spell checking implementation myself: find all
word pairs in text segment where spelling differs by one character,
indicate any word with a frequency count of 1 as suspect. (I know this is
not a perfect solution.)
My question: what is the name for the class of algorithms that deal with
this problem?

jquery issue , first stop if second works

jquery issue , first stop if second works

I have written 1) scripts using datatable.js to show data
2) autocomplete method
PortletDraggable.init();
FormFileUpload.init();
EducationalQualification.init();
WorkExperience.init();
Supervisions.init();
Awards.init();
Publication.init();
All these are datatable methods working properly. But when I add
jquery.auto-complete.js script reference, these methods stop working and
autocomplete start working.
Where is the problem, please suggest.
<script>
$('.date-picker').datepicker({
format: 'mm/dd/yyyy'
});
// var oTable = null;
jQuery(document).ready(function () {
App.init();
PortletDraggable.init();
FormFileUpload.init();
EducationalQualification.init();
WorkExperience.init();
Supervisions.init();
Awards.init();
Publication.init();
});
var tmpMem = 0; var tmpAward = 0; var tmpPub = 0;
// Js For Autocomplete
$('input[name=SearchUser]').autocomplete({
source: function (request, response) {
tmpMem = 0; tmpAward = 0; tmpPub = 0;
$.ajax({
type: 'GET',
url: '@Url.Action("SearchUser", "Profile")',
data: { FirstName: $("#SearchUser").val() },
// url: "/Profile/SearchUser?FirstName=" +
$("#SearchUser").val(),
contentType: "application/json; charset=utf-8",
// dataType: "json",
beforeSend: function () {
// code to show loading image
//$(".ui-content").css("opacity", "0.4");
//$("#imgLoader").attr("style", "display:block");
//var df = document.getElementById('imgLoader');
//df.style.position = 'absolute';
//var wd = ($(window).width() / 2) - 45;
//var hg = ($(window).height() / 2) - 60;
//df.style.left = wd + "px";
//df.style.top = hg + "px";
},
complete: function () {
//hide loading image
$(".ui-content").css("opacity", "1.0");
$("#imgLoader").attr("style", "display:none");
},
success: function (data) {
alert(data.data[0].Fname);
response($.map(data.data, function (item) {
return {
Sn: item.Sn, Fname: item.Fname, Mname:
item.Uname, Lname: item.Lname, Title:
item.Title,
Image: item.Image, Organization:
item.Organization, JobTitle:
item.JobTitle,
Awardname: item.Awardname, AwardYear:
item.AwardYear, Pubname: item.Pubname,
Pubtype: item.Pubtype, TabType:
item.TabType
}
}))
}
})
},
select: function (event, ui) {
//var domainURL = $("#domainurl").val();
//window.location = domainURL +
"/home/NeighborProfile?id=" + ui.item.id;
// alert(ui.item.Sn);
}
}).data("autocomplete")._renderItem = function (ul, item) {
// alert(item);="
if (item.TabType == "member") {
if (tmpMem == 0) {
tmpMem = 1;
return $("<li
class='SearchUserLi'></li>").data("item.autocomplete",
item).append(
"<a href=' ' class='SearchUserLink'>" +
"<img src='" + item.Image + "' alt='" + item.Fname
+ "' class='SearchUserImg'>" +
"<span class='searchUserLight'>" +
item.Title + ". " + item.Fname +
"<span style=' font-weight:
bold;color:black'>" + " " +
item.Organization + "</span>" +
"</span>" +
"<span style=' font-size : 10px; color:
#3B5998;'>" + item.JobTitle + "</span>" +
"</a>"
).prepend("<span class='SearchUsercategory'> Members
</span>").appendTo(ul);
}
return $("<li
class='SearchUserLi'></li>").data("item.autocomplete",
item).append(
"<hr class='SearchUserHr'>" +
"<a href=' ' class='SearchUserLink'>" +
"<img src='" + item.Image + "' alt='" +
item.Fname + "' class='SearchUserImg'>" +
"<span class='searchUserLight'>" +
item.Title + ". " + item.Fname +
"<span style=' font-weight:
bold;color:black'>" + " " +
item.Organization + "</span>" +
"</span>" +
"<span style=' font-size : 10px; color:
#3B5998;'>" + item.JobTitle + "</span>" +
"</a>"
).appendTo(ul);
}
else if (item.TabType == "award") {
if (tmpAward == 0) {
tmpAward = 1;
return $("<li
style='padding:0px!important;height:80px'></li>").data("item.autocomplete",
item).append(
"<a href=' ' class='SearchUserLink'>" +
"<img src='" + item.Image + "' alt='" + item.Fname
+ "' class='SearchUserImg'>" +
"<span class='searchUserLight'>" +
item.Title + ". " + item.Fname +
"<span style=' font-weight:
bold;color:black'>" + " " +
item.Organization + "</span>" +
"</span>" +
"<span style=' font-size : 10px; color:
#3B5998;'>" + " " + item.Awardname + "(" +
item.AwardYear + ")" + "</span>" +
"</a>"
).prepend("<span class='SearchUsercategory'> Awards
</span>").appendTo(ul)
}
return $("<li
style='padding:0px!important;height:80px'></li>").data("item.autocomplete",
item).append(
"<hr class='SearchUserHr'>" +
"<a href=' ' class='SearchUserLink'>" +
"<img src='" + item.Image + "' alt='" +
item.Fname + "' class='SearchUserImg'>" +
"<span class='searchUserLight'>" +
item.Title + ". " + item.Fname +
"<span style=' font-weight:
bold;color:black'>" + " " +
item.Organization + "</span>" +
"</span>" +
"<span style=' font-size : 10px; color:
#3B5998;'>" + " " + item.Awardname + "(" +
item.AwardYear + ")" + "</span>" +
"</a>"
).appendTo(ul);
}
else if (item.TabType == "publications") {
if (tmpPub == 0) {
tmpPub = 1;
return $("<li
style='padding:0px!important;height:80px'></li>").data("item.autocomplete",
item).append(
"<a href=' ' class='SearchUserLink'>" +
"<img src='" + item.Image + "' alt='" + item.Fname
+ "' class='SearchUserImg'>" +
"<span class='searchUserLight'>" +
item.Title + ". " + item.Fname +
"<span style=' font-weight:
bold;color:black'>" + " " +
item.Organization + "</span>" +
"</span>" +
"<span style=' font-size : 10px; color:
#3B5998;'>" + " " + item.Pubname + "," +
item.Pubtype + "</span>" +
"</a>"
).prepend("<span class='SearchUsercategory'>
Publications </span>").appendTo(ul)
}
return $("<li
style='padding:0px!important;height:80px'></li>").data("item.autocomplete",
item).append(
"<hr class='SearchUserHr'>" +
"<a href=' ' class='SearchUserLink'>" +
"<img src='" + item.Image + "' alt='" +
item.Fname + "' class='SearchUserImg'>" +
"<span class='searchUserLight'>" +
item.Title + ". " + item.Fname +
"<span style=' font-weight:
bold;color:black'>" + " " +
item.Organization + "</span>" +
"</span>" +
"<span style=' font-size : 10px; color:
#3B5998;'>" + " " + item.Pubname + "," +
item.Pubtype + "</span>" +
"</a>"
).appendTo(ul);
}
};
</script>