algorithm complexity , solving recursive equation
I am a student at University of Tehran and this semester I've taken a Data
Structures and Algorithm course . anyway not to bore you with details ,
for solving complexity for an algorithm , I'm stuck in this recursive
equation :
T(n) = logn*T(logn) + n
obviously this cant be handled with the use of the Master Theorem , so I
was wondering if anybody has any ideas for solving this recursive equation
. P.S. : I'm pretty sure that it should be solved with a change in the
parameters , like considering n to be 2^m , but I couldn't manage to find
any good fix . anyways , thanks for your help in advance
Borchard
Thursday, 3 October 2013
Wednesday, 2 October 2013
Release bugs only show up when running EXE outside of Visual Studio
Release bugs only show up when running EXE outside of Visual Studio
I have an issue that I am trying to debug that only happens when I run the
release exe built directly outside of Visual Studio. When I am executing
it from within Visual Studio the program behaves normally, even when using
specific project properties to debug a "release" build, such as turning on
optimizations, explained on the following page.
http://msdn.microsoft.com/en-us/library/fsk896zz%28v=vs.100%29.aspx
I experience no issues using those settings and running/debugging from
withing VS, but when I copy the exe and required files (images and some
dll) to it's own directory and run the exe directly instead of through
VS2010 I experience a couple errors. This is making it hard to debug as I
can't get the issue to occur inside VS no matter what settings I use.
Am I missing some settings or is there still more things that happen
differently outside of VS2010 that I can't simulate from within VS 2010?
I am not using any arguments or environment variables that could be
affecting it and the file structure from the working directory is
identical to the way it is in the source code directory.
I have an issue that I am trying to debug that only happens when I run the
release exe built directly outside of Visual Studio. When I am executing
it from within Visual Studio the program behaves normally, even when using
specific project properties to debug a "release" build, such as turning on
optimizations, explained on the following page.
http://msdn.microsoft.com/en-us/library/fsk896zz%28v=vs.100%29.aspx
I experience no issues using those settings and running/debugging from
withing VS, but when I copy the exe and required files (images and some
dll) to it's own directory and run the exe directly instead of through
VS2010 I experience a couple errors. This is making it hard to debug as I
can't get the issue to occur inside VS no matter what settings I use.
Am I missing some settings or is there still more things that happen
differently outside of VS2010 that I can't simulate from within VS 2010?
I am not using any arguments or environment variables that could be
affecting it and the file structure from the working directory is
identical to the way it is in the source code directory.
How to create a kernel thread in atomic context and use it multiple times [BUG: Scheduling while atomic]
How to create a kernel thread in atomic context and use it multiple times
[BUG: Scheduling while atomic]
I need to kthread_run in a driver kernel code. This thread tends to turns
an LED on/OFF where the device is transmitting data. So basically I won't
want the transmission be slowed down be cause of the LED blinking delay
time. I would like to create a thread somewhere around packet transmission
code so the thread will do the LED blinking process based on the rate of
transmission. But apparently creating a thread there requires interaction
with the thread scheduler, which is not allowed at interrupt/atomic
context and will generate the BUG:Scheduling while atomic. according to my
research,an approach could be to create the kernel thread elsewhere, and
queue interrupt request processing to it. Can someone please elaborate
this a bit more? So this is not a case where we have interruption thread.
I basically need a Function that has it's own thread away from my main
thread. And I will call this function anytime! Please let me know if this
is still unclear. Thanks.
[BUG: Scheduling while atomic]
I need to kthread_run in a driver kernel code. This thread tends to turns
an LED on/OFF where the device is transmitting data. So basically I won't
want the transmission be slowed down be cause of the LED blinking delay
time. I would like to create a thread somewhere around packet transmission
code so the thread will do the LED blinking process based on the rate of
transmission. But apparently creating a thread there requires interaction
with the thread scheduler, which is not allowed at interrupt/atomic
context and will generate the BUG:Scheduling while atomic. according to my
research,an approach could be to create the kernel thread elsewhere, and
queue interrupt request processing to it. Can someone please elaborate
this a bit more? So this is not a case where we have interruption thread.
I basically need a Function that has it's own thread away from my main
thread. And I will call this function anytime! Please let me know if this
is still unclear. Thanks.
Popup message after redirect OR message after user visits from a particular site
Popup message after redirect OR message after user visits from a
particular site
I'd like to show a popup welcome message AFTER a visitor has been
redirected from my old site to the new one.
I'm going to set up the old site with 301 redirects to the new content -
and only people coming from the old site should see the welcome message.
Users who access the new site directly should not see the message.
I know that I can set up a message before redirect on the old site - but I
currently only have access to my client's new site.
I can't find anything anywhere about doing something like this. Is it
possible?
particular site
I'd like to show a popup welcome message AFTER a visitor has been
redirected from my old site to the new one.
I'm going to set up the old site with 301 redirects to the new content -
and only people coming from the old site should see the welcome message.
Users who access the new site directly should not see the message.
I know that I can set up a message before redirect on the old site - but I
currently only have access to my client's new site.
I can't find anything anywhere about doing something like this. Is it
possible?
How to use variables in Java?
How to use variables in Java?
This question may seem dumb at first, but after having worked with
different person, I see everyone seems to have their own, different
knowledge about it, so here's my question.
So now I'm wondering what is the best way to do it, and why (why is more
important for me):
I'm wondering about two methods to write Java code:
Do you always pass Object or can you pass primitive data type ?
Do you call variables using this.name, name or getName() inside your class
instance ?
public class MyClass {
private String someStr;
private int someNumber;
private Integer someOtherNumber; // int, Integer ? which one to choose ?
public MyClass(String someStr, int someNumber, int someOtherNumber) {
// int someNumber ? Integer someNumber ? why ?
this.someStr = someStr; // Here, it's clearly this.{name} = {name}
because of the variable name conflict
this.someNumber = someNumber;
this.someOtherNumber = someOtherNumber;
}
public int someMethod(boolean first) { // Boolean ? boolean ?
if (first) {
return someNumber;
} else {
return this.someOtherNumber; // this.{name} ? just {name} or
even this.get{name}() or get{name}() ? (supposing getters
exists)
}
}
}
I hope I'm clear about it and I hope someone will provide me with a great
explanation about which to use in order for me to write better code (and
maybe help others too ! :))
Thanks for your help.
This question may seem dumb at first, but after having worked with
different person, I see everyone seems to have their own, different
knowledge about it, so here's my question.
So now I'm wondering what is the best way to do it, and why (why is more
important for me):
I'm wondering about two methods to write Java code:
Do you always pass Object or can you pass primitive data type ?
Do you call variables using this.name, name or getName() inside your class
instance ?
public class MyClass {
private String someStr;
private int someNumber;
private Integer someOtherNumber; // int, Integer ? which one to choose ?
public MyClass(String someStr, int someNumber, int someOtherNumber) {
// int someNumber ? Integer someNumber ? why ?
this.someStr = someStr; // Here, it's clearly this.{name} = {name}
because of the variable name conflict
this.someNumber = someNumber;
this.someOtherNumber = someOtherNumber;
}
public int someMethod(boolean first) { // Boolean ? boolean ?
if (first) {
return someNumber;
} else {
return this.someOtherNumber; // this.{name} ? just {name} or
even this.get{name}() or get{name}() ? (supposing getters
exists)
}
}
}
I hope I'm clear about it and I hope someone will provide me with a great
explanation about which to use in order for me to write better code (and
maybe help others too ! :))
Thanks for your help.
Tuesday, 1 October 2013
Is it a common/good practice to save/update the session *after* sending the response?
Is it a common/good practice to save/update the session *after* sending
the response?
I started updating the session after sending the response and it seems
like a good way to get a little more speed, since it's now a non-blocking
task.
But I'm worried that a minimal slow down in the database could cause
problems when updating the session this way.
Imagine I want to set a session flash message for the next request, but
the next request/response happen before the session is updated. The user
won't see it, or he will see it in a different request.
And the worst case is when you need to regenerate the session ID. If the
update is slow and the next request comes faster than that, the user will
get logged out because he will be asking for a non-existent or expired
session (he received the new session ID in the cookie as part of the
response).
So what I wanna know is whether this has already been studied, whether
people are using it, when should I do it, when I shouldn't, if there is a
fix for it, etc.
the response?
I started updating the session after sending the response and it seems
like a good way to get a little more speed, since it's now a non-blocking
task.
But I'm worried that a minimal slow down in the database could cause
problems when updating the session this way.
Imagine I want to set a session flash message for the next request, but
the next request/response happen before the session is updated. The user
won't see it, or he will see it in a different request.
And the worst case is when you need to regenerate the session ID. If the
update is slow and the next request comes faster than that, the user will
get logged out because he will be asking for a non-existent or expired
session (he received the new session ID in the cookie as part of the
response).
So what I wanna know is whether this has already been studied, whether
people are using it, when should I do it, when I shouldn't, if there is a
fix for it, etc.
spring security bean not found exception
spring security bean not found exception
I'm trying to set up spring security for an mvc project, and I'm having a
hard time. I'm using the spring security 3.1.4.Release. I have a
spring-security.xml file set up along with and mvc-dispatcher-servlet file
set up for configuration. Right now I'm getting a bean not found exception
for my User Details Bean.
In intellij I get a "cannot resolve bean" message for the
myUserDetailService. I also cannot resolve the package "controller". The
root error when I run the project is:
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':
Cannot resolve reference to bean 'myUserDetailService' while setting bean
property 'userDetailsService'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'myUserDetailService' is defined
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
Here is my spring-security.xml file:
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- Enabling Spring beans auto-discovery -->
<context:component-scan base-package="controller, com.company.admin" />
<http auto-config="true">
<intercept-url pattern="/admin/*" access="ROLE_USER" />
<form-login login-page="/login" default-target-url="/admin/welcome"
authentication-failure-url="/loginfailed" />
<logout logout-success-url="/logout" />
</http>
<authentication-manager>
<authentication-provider user-service-ref="myUserDetailService"/>
</authentication-manager>
</beans:beans>
Here is my mvc-dispatcher-servlet.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- Enabling Spring beans auto-discovery -->
<context:component-scan base-package="com.company.admin" />
<!-- Enabling Spring MVC configuration through annotations -->
<mvc:annotation-driven />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
Here is my web.xml:
<web-app version="2.4"
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">
<display-name>Spring MVC Application</display-name>
<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>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/mvc-dispatcher-servlet.xml,
/WEB-INF/spring-security.xml
</param-value>
</context-param>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
I'm basically trying to follow this tutorial:
http://kh-yiu.blogspot.com/2012/12/spring-mvc-security-custom.html and the
UserDetailServiceImpl is pretty identical to that, but I do have it in a
different folder in my main/java directory. It's important to note I use
annotations to declare the class:
@Service("myUserDetailService")
public class UserDetailsServiceImpl implements UserDetailsService{
Any ideas? I'm having a very hard time finding tutorials with the same
spring version that I'm using, so it's quite possible I've messed up xsd
refs. Thanks.
I'm trying to set up spring security for an mvc project, and I'm having a
hard time. I'm using the spring security 3.1.4.Release. I have a
spring-security.xml file set up along with and mvc-dispatcher-servlet file
set up for configuration. Right now I'm getting a bean not found exception
for my User Details Bean.
In intellij I get a "cannot resolve bean" message for the
myUserDetailService. I also cannot resolve the package "controller". The
root error when I run the project is:
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':
Cannot resolve reference to bean 'myUserDetailService' while setting bean
property 'userDetailsService'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'myUserDetailService' is defined
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
Here is my spring-security.xml file:
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- Enabling Spring beans auto-discovery -->
<context:component-scan base-package="controller, com.company.admin" />
<http auto-config="true">
<intercept-url pattern="/admin/*" access="ROLE_USER" />
<form-login login-page="/login" default-target-url="/admin/welcome"
authentication-failure-url="/loginfailed" />
<logout logout-success-url="/logout" />
</http>
<authentication-manager>
<authentication-provider user-service-ref="myUserDetailService"/>
</authentication-manager>
</beans:beans>
Here is my mvc-dispatcher-servlet.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- Enabling Spring beans auto-discovery -->
<context:component-scan base-package="com.company.admin" />
<!-- Enabling Spring MVC configuration through annotations -->
<mvc:annotation-driven />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
Here is my web.xml:
<web-app version="2.4"
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">
<display-name>Spring MVC Application</display-name>
<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>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/mvc-dispatcher-servlet.xml,
/WEB-INF/spring-security.xml
</param-value>
</context-param>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
I'm basically trying to follow this tutorial:
http://kh-yiu.blogspot.com/2012/12/spring-mvc-security-custom.html and the
UserDetailServiceImpl is pretty identical to that, but I do have it in a
different folder in my main/java directory. It's important to note I use
annotations to declare the class:
@Service("myUserDetailService")
public class UserDetailsServiceImpl implements UserDetailsService{
Any ideas? I'm having a very hard time finding tutorials with the same
spring version that I'm using, so it's quite possible I've messed up xsd
refs. Thanks.
Subscribe to:
Comments (Atom)