I would like to assign a value in a class property dynamically (that is referring to it using a variable).
#Something like:
setPropValue($obj, $propName, $value);
Hi,
I'm trying to read a file byte by byte, but I'm not sure how to do that. I'm trying to do it like that:
file = open(filename, 'rb')
while 1:
byte = file.read(8)
# Do something...
So does that make the variable byte to contain 8 next bits at the beginning of every loop? It doesn't matter what those bytes really are. The only thing that matters is that I need to read a file in 8-bit stacks.
I'm trying to implement a Chord distributed hash table. I want to use SHA-1 as the hash function to generate node ids and map values to the DHT. However, I'll need to use numerical operations on the SHA-1 generated key, such as a modulo, for example. I wonder in which type of variable should I put the array of bytes I get, and how can I convert from one to another.
Hi,
I would like to add on the right column of my site a rotating references section. Each reference would have some text + name of person + company name. It does not need to be structured (open text is also ok).
I would then want opencms to rotate between 20 difference references each time a page is displayed. I can keep a session scope counter holding which reference we last showed.
I need a way to manage the references (users not programmers) over time.
My question is which would be the best way to do so?
Thanks
Could really use with some help here...
I've got a servlet that generates an XML string (relatively long) which I then pass to a javascript variable in a forwarded jsp file:
$(document).ready(function() {
...
var itXML = <% out.print((String)request.getAttribute("xml"));% ;
...
}
This seems to work just fine in Firefox but when I run the same project on IE8 I get a syntax error for this line.
Any Ideas?
Thanks!
I'm trying to make very simple Spring 3 + JSF2.1 integration according to examples I googled in the web.
So here is my code:
My HTML submitted to actionController.actionSubmitted() method:
<h:form>
<h:message for="textPanel" style="color:red;" />
<h:panelGrid columns="3" rows="5" id="textPanel">
//all my bean prperties mapped to HTML code.
</h:panelGrid>
<h:commandButton value="Submit" action="#{actionController.actionSubmitted}" />
</h:form>
now the Action Controller itself:
@ManagedBean(name="actionController")
@SessionScoped
public class ActionController implements Serializable{
@ManagedProperty(value="#{user}")
User user;
@ManagedProperty(value="#{mailService}")
MailService mailService;
public void setMailService(MailService mailService) {
this.mailService = mailService;
}
public void setUser(User user) {
this.user = user;
}
private static final long serialVersionUID = 1L;
public ActionController() {}
public String actionSubmitted(){
System.out.println(user.getEmail());
mailService.sendUserMail(user);
return "success";
}
}
Now my bean Spring:
public interface MailService {
void sendUserMail(User user);
}
public class MailServiceImpl implements MailService{
@Override
public void sendUserMail(User user) {
System.out.println("Mail to "+user.getEmail()+" sent." );
}
}
This is my web.xml
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<!-- Welcome page -->
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<!-- JSF mapping -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
my applicationContext.xml
<beans xmlns="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">
<bean id="mailService" class="com.vanilla.jsf.services.MailServiceImpl">
</bean>
</beans>
my faces-config.xml is the following:
<application>
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
<message-bundle>
com.vanilla.jsf.validators.MyMessages
</message-bundle>
</application>
<managed-bean>
<managed-bean-name>actionController</managed-bean-name>
<managed-bean-class>com.vanilla.jsf.controllers.ActionController</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>mailService</property-name>
<value>#{mailService}</value>
</managed-property>
</managed-bean>
<navigation-rule>
<from-view-id>index.xhtml</from-view-id>
<navigation-case>
<from-action>#{actionController.actionSubmitted}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>submitted.xhtml</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
My Problem is that I'm getting NullPointerExeption because my mailService Spring bean is null.
public String actionSubmitted(){
System.out.println(user.getEmail());
//mailService is null Getting NullPointerException
mailService.sendUserMail(user);
return "success";
}
Before Entering data into a database, I just want to check that the database doesn't have the same username in the database already.
I have the username in SQL set as a key, so it can't be duplicated on that end, but I am looking at finding a more user-friendly error message then "KEY already exists".
Is there are simple way to check if the variable value already exists in a row?
Thanks!
Hey all. Newbie JavaScript question here. I have an array: {r=1, g=4, b=6} How do i go about getting the value of each (r,g,b) into a separate variable?
I have a form page in PHP that reads a DBF, and conditionally converts it into a MySQL - extracting the data from an old, but still production accounting app. The conversion should be able to be actioned without user intervention, ie scripted from the web-host's command line on a cron job.
How can I get PHP to submit the form automatically when receiving variables at command line, like for instance a specific post variable? Every auto-submit I've found so far relied upon javascript, which would be useless at PHP command line.
In Python I have a list of n lists, each with a variable number of elements. How can I create a single list containing all the possible permutations:
For example
[ [ a, b, c], [d], [e, f] ]
I want
[ [a, d, e] , [a, d, f], [b, d, e], [b, d, f], [c, d, e], [c, d, f] ]
Note I don't know n in advance. I thought itertools.product would be the right approach but it requires me to know the number of arguments in advance
Hey,
I have this mysql tables I want to display with jqgrid. The problem appears when I want to display a parametrized query.
For example lets say I want to display all students older than 21. I have this variable named age which I want to pass to server.php file where I can construct the XML or JSON.
On server I see some variables like $examp = $_REQUEST["q"]; but I dont know where to put $age to be accesed in server.php
Thanks
i want to return wchar_t frm a function. How can i implement it
wchar_t wcstring1[newsize1]
How to return "wcstring1" from a function and make it to save into another variable of same type(In another function)
Say I'm writing a Django app, and all the templates in the app require a certain variable.
The "classic" way to deal with this, afaik, is to write a context processor and add it to TEMPLATE_CONTEXT_PROCESSORS in the settings.py.
My question is, is this the right way to do it, considering that apps are supposed to be "independent" from the actual project using them?
In other words, when deploying that app to a new project, is there any way to avoid the project having to explicitly mess around with its settings?
I get the following errors:
error: missing terminating " character
and
error: stray `\' in program
In this line of C code:
system("sqlite3 -html /home/user/.rtcom-eventlogger/el.db \"SELECT service_id, event_type_id,free_text, remote_uid FROM Events WHERE remote_uid=\'%d\' ORDER BY start_time DESC;\" > lol.html", nr);
"nr" is a integer variable.
I have gone over this so many times but are totally stuck of finding a solution.
EDIT: The errors is the ouput while compiling with gcc if I didn't make that clear.
I'm trying to program a Hebrew site with a search option.
I am using php 5 with Apache 2.2, on a Debian 5 (Lenny) with
appropriate code pages enabled.
I am using _POST to pass arguments to a script. If I pass
English word to the script everything works, but when I use Hebrew
nothing is passed through the POST function. When I use ECHO
to show _POST, the variable is empty.
What might be the problem?
Hi,
When i include fb_connect_async_js javascript helper it is throwing an
error , Facebooker 2 don't have action view template. Could you please tell
me how handle this situation .
undefined local variable or method `fb_connect_async_js' for
ActionView::Base
Thanks,
Srini
I have a formula which is working; the formula uses an array. I tried to extract the formula to create a custom formula but now get an error in the syntax.
I am wondering if the array is causing the problem as the error is on the line:
last_element_current:=val(sc_array[1]) + 1;
and the error is: the ) is missing and highlights the variable sc_array before the index [1].
I wonder if syntax as follows would be helpful in your opinion as a code readability improvent and self-commenting of code:
std::map<std::string name, std::vector<int> scores> myMap;
In this example it clearly says and no other comment is needed, what for we are using myMap variable.
Looking forward to your opinions.
In C I did not notice any effect of the extern keyword used before function declaration.
At first I thougth that when defining extern int f(); in a single file forces you to implement it outside of the files scope, however I found out that both
extern int f();
int f() {return 0;}
And
extern int f() {return 0;}
Compiles just fine, with no warnings from gcc. I used gcc -Wall -ansi, he wouldn't even accept // comments.
Are there any effects for using extern before function definitions? Or is it just an optional keyword with no side effects for functions.
In the latter case I don't understand why did the standard designers chose to litter the grammar with superfluous keywords.
EDIT: to clarify, I know there's usage for extern in variables, but I'm only asking about extern in functions.
Given a class like this:
class B
class << self
attr_accessor :var
end
end
Suppose I can't modify the original source code of class B. How might I go about removing the setter on the class variable var? I've tried using something like B.send("unset_method", "var="), but that doesn't work (nor does remove_method, or overwriting that method with a var= method that doesn't do anything). Any ideas?
This probably an easy thing to do but for some reason I can't get a handle on it.
I have a simple form that allows people to select one if three items for sale. When they chose their item I need to pass that variable into an iFrame with a third party checkout page to safely process their cc transaction.
How would I do this?
Cheers-
I have an expression that gives a matrix and I want to access an element, without creating a temporary variable, something like this cov(M)(1,1). How can I do it?
Thanks!