syntax error unexpected T_ENCAPSED... php
Probably a really simple one to do with quotes but php is not my thing!
"INSERT INTO feedback_test (FirstName, LastName, Age) VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')"
getting the error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING
or T_VARIABLE or T_NUM_STRING
Thursday, 3 October 2013
Wednesday, 2 October 2013
Relative lyaout in Android
Relative lyaout in Android
I am making an android app for diabetic patients. In that app I want to
show the food item with their quantity for every meal for diet control. It
should look somewhat like below:
RICE 100gm
POTATO 50gm
FISH 60gm
Those info will be obtained from my database dynamically. However I am
facing problem arranging them. I want the food items to be aligned left
and quantity aligned right of the screen. As below (dots denote the screen
)
|-------------------------------------------------------|
|RICE 100gm |
|POTATO 50gm |
|FISH 60gm |
|-------------------------------------------------------|
To do that I have declared a relative Layout in xml file. The code looks
as below :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</RelativeLayout>
</LinearLayout>
All I need to do now is to create textview and add them to this relative
layout dynamically. But I am confused how to do that. Any hint please...
The final output should look something like below :
I am making an android app for diabetic patients. In that app I want to
show the food item with their quantity for every meal for diet control. It
should look somewhat like below:
RICE 100gm
POTATO 50gm
FISH 60gm
Those info will be obtained from my database dynamically. However I am
facing problem arranging them. I want the food items to be aligned left
and quantity aligned right of the screen. As below (dots denote the screen
)
|-------------------------------------------------------|
|RICE 100gm |
|POTATO 50gm |
|FISH 60gm |
|-------------------------------------------------------|
To do that I have declared a relative Layout in xml file. The code looks
as below :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</RelativeLayout>
</LinearLayout>
All I need to do now is to create textview and add them to this relative
layout dynamically. But I am confused how to do that. Any hint please...
The final output should look something like below :
Prove if $a|b$ and $b|a$, then $|a|=|b|$ , $a, b$ are integers.
Prove if $a|b$ and $b|a$, then $|a|=|b|$ , $a, b$ are integers.
Form the assumption, we can say $b=ak$ ,$k$ integer, $a=bm$, $m$ integer.
Intuitively, this conjecture makes sense.But I can't make further step.
Form the assumption, we can say $b=ak$ ,$k$ integer, $a=bm$, $m$ integer.
Intuitively, this conjecture makes sense.But I can't make further step.
ListView does not resize when hiding element(s) dynamically
ListView does not resize when hiding element(s) dynamically
I have a menu ListView that has a dynamic SignOut button that should only
show when the user is logged in. The ListView has a drop shadow after it
(not set as a Footer, but rather as a View following the ListView). When I
remove the SignOut button it disappears, but the size of the ListView does
not change, so there is a transparent gap and then the dropshadow. I am
hiding the SignOut row using signOutBtn.setVisibility(View.GONE); (I have
a reference to the signOutBtn view). Also, I have verified I am not using
View.INVISIBLE anywhere since I would expect this behavior using that.
The ListView is using wrap_content for the height, and I believe this is
where the problem lies - the height is being calculated including the
SignOut button.
So, the question is, how can I make the ListView dynamically resize when a
row is shown or hidden? I would prefer not to destroy and recreate the
View, although that is what I will probably try next, since it is a
relatively simple view.
PS. I can add code samples if needed, but I do not believe this is a code
issue.
I have a menu ListView that has a dynamic SignOut button that should only
show when the user is logged in. The ListView has a drop shadow after it
(not set as a Footer, but rather as a View following the ListView). When I
remove the SignOut button it disappears, but the size of the ListView does
not change, so there is a transparent gap and then the dropshadow. I am
hiding the SignOut row using signOutBtn.setVisibility(View.GONE); (I have
a reference to the signOutBtn view). Also, I have verified I am not using
View.INVISIBLE anywhere since I would expect this behavior using that.
The ListView is using wrap_content for the height, and I believe this is
where the problem lies - the height is being calculated including the
SignOut button.
So, the question is, how can I make the ListView dynamically resize when a
row is shown or hidden? I would prefer not to destroy and recreate the
View, although that is what I will probably try next, since it is a
relatively simple view.
PS. I can add code samples if needed, but I do not believe this is a code
issue.
Dynamic creation of SVG links in JavaScript
Dynamic creation of SVG links in JavaScript
I am dynamically creating SVG elements from JavaScript. It's working fine
for visual objects like a rectangle, but I'm having trouble producing
functioning xlinks. In the example below the first rectangle (which is
statically defined) works correctly when clicked on, but the other two
(created in JavaScript) ignore clicks... even though inspecting the
elements in Chrome seems to show the same structure.
I've seen multiple similar questions come up, but none that exactly
address this. The closest I found was [ adding image namespace in svg
through JS still doesn't show me the picture ] but that's not working (as
noted below). My goal is to do this purely in JavaScript, without
depending on JQuery or other libraries.
<!-- Static - this rectangle draws and responds to click -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" id="svgTag">
<a xlink:href="page2.html" id="buttonTemplate">
<rect x="20" y="20" width="200" height="50" fill="red"
class="linkRect"/>
</a>
</svg>
<script>
var svgElement = document.getElementById ("svgTag");
// Dynamic attempt #1 - draws but doesn't respond to clicks
var link = document.createElementNS("http://www.w3.org/2000/svg",
"a"); // using http://www.w3.org/1999/xlink for NS prevents drawing
link.setAttribute ("xlink:href", "page2.html"); // no improvement
with setAttributeNS
svgElement.appendChild(link);
var box = document.createElementNS("http://www.w3.org/2000/svg", "rect");
box.setAttribute("x", 30);
box.setAttribute("y", 30);
box.setAttribute("width", 200);
box.setAttribute("height", 50);
box.setAttribute("fill", "blue");
link.appendChild(box);
// Dynamic attempt #2 (also draws & doesn't respond) - per
http://stackoverflow.com/questions/6893391
box = document.createElementNS("http://www.w3.org/2000/svg", "rect");
box.setAttribute("x", 40);
box.setAttribute("y", 40);
box.setAttribute("width", 200);
box.setAttribute("height", 50);
box.setAttribute("fill", "green");
box.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href',
"page2.html");
svgElement.appendChild(box);
I am dynamically creating SVG elements from JavaScript. It's working fine
for visual objects like a rectangle, but I'm having trouble producing
functioning xlinks. In the example below the first rectangle (which is
statically defined) works correctly when clicked on, but the other two
(created in JavaScript) ignore clicks... even though inspecting the
elements in Chrome seems to show the same structure.
I've seen multiple similar questions come up, but none that exactly
address this. The closest I found was [ adding image namespace in svg
through JS still doesn't show me the picture ] but that's not working (as
noted below). My goal is to do this purely in JavaScript, without
depending on JQuery or other libraries.
<!-- Static - this rectangle draws and responds to click -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" id="svgTag">
<a xlink:href="page2.html" id="buttonTemplate">
<rect x="20" y="20" width="200" height="50" fill="red"
class="linkRect"/>
</a>
</svg>
<script>
var svgElement = document.getElementById ("svgTag");
// Dynamic attempt #1 - draws but doesn't respond to clicks
var link = document.createElementNS("http://www.w3.org/2000/svg",
"a"); // using http://www.w3.org/1999/xlink for NS prevents drawing
link.setAttribute ("xlink:href", "page2.html"); // no improvement
with setAttributeNS
svgElement.appendChild(link);
var box = document.createElementNS("http://www.w3.org/2000/svg", "rect");
box.setAttribute("x", 30);
box.setAttribute("y", 30);
box.setAttribute("width", 200);
box.setAttribute("height", 50);
box.setAttribute("fill", "blue");
link.appendChild(box);
// Dynamic attempt #2 (also draws & doesn't respond) - per
http://stackoverflow.com/questions/6893391
box = document.createElementNS("http://www.w3.org/2000/svg", "rect");
box.setAttribute("x", 40);
box.setAttribute("y", 40);
box.setAttribute("width", 200);
box.setAttribute("height", 50);
box.setAttribute("fill", "green");
box.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href',
"page2.html");
svgElement.appendChild(box);
Tuesday, 1 October 2013
HQL between two time interval
HQL between two time interval
How is the correct format to use a HQL between 2 intervals of date times.
I have this SQL in oracle:
select * from vw_diariorecauda where ts_crea between TO_DATE
('01/10/2013 00:00:00','dd/MM/yyyy hh24:mi:ss')
and TO_DATE ('01/10/2013 23:59:59', 'dd/MM/yyyy hh24:mi:ss')
My HQl:
**the field:**
private Date tsCrea;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "TS_CREA")
public Date getTsCrea() {
return this.tsCrea;
}
**DAO:**
public List<VwDiariorecauda> buscarFecha(Date fecha) {
log.trace(fecha);
Calendar c = Calendar.getInstance();
c.setTime(fecha);
c.add(Calendar.HOUR, 0);
c.add(Calendar.MINUTE, 0);
c.add(Calendar.SECOND, 0);
Date fInicio = c.getTime();
c.add(Calendar.HOUR, 23);
c.add(Calendar.MINUTE, 59);
c.add(Calendar.SECOND, 59);
Date fFin = c.getTime();
Session session = sessionFactory.getCurrentSession();
Query query=session.createQuery("FROM VwDiariorecauda WHERE
tsCrea BETWEEN :hora1 AND
:hora2").setTimestamp("hora1",fInicio).
setTimestamp("hora2",fFin);
return query.list();
the hql works good but the results is different with the simple sql. How
can I improve this hql.
Thanks in advance.
How is the correct format to use a HQL between 2 intervals of date times.
I have this SQL in oracle:
select * from vw_diariorecauda where ts_crea between TO_DATE
('01/10/2013 00:00:00','dd/MM/yyyy hh24:mi:ss')
and TO_DATE ('01/10/2013 23:59:59', 'dd/MM/yyyy hh24:mi:ss')
My HQl:
**the field:**
private Date tsCrea;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "TS_CREA")
public Date getTsCrea() {
return this.tsCrea;
}
**DAO:**
public List<VwDiariorecauda> buscarFecha(Date fecha) {
log.trace(fecha);
Calendar c = Calendar.getInstance();
c.setTime(fecha);
c.add(Calendar.HOUR, 0);
c.add(Calendar.MINUTE, 0);
c.add(Calendar.SECOND, 0);
Date fInicio = c.getTime();
c.add(Calendar.HOUR, 23);
c.add(Calendar.MINUTE, 59);
c.add(Calendar.SECOND, 59);
Date fFin = c.getTime();
Session session = sessionFactory.getCurrentSession();
Query query=session.createQuery("FROM VwDiariorecauda WHERE
tsCrea BETWEEN :hora1 AND
:hora2").setTimestamp("hora1",fInicio).
setTimestamp("hora2",fFin);
return query.list();
the hql works good but the results is different with the simple sql. How
can I improve this hql.
Thanks in advance.
How do I asynchronously map values onto a function with threading?
How do I asynchronously map values onto a function with threading?
I'm trying to learn how to execute "embarrassingly" parallel tasks in
C++11. A common pattern I come across is get the result of a function when
evaluated over a range of values, similar to calling python's
multiprocessing.Pool.map. I've written a minimal example that shows what I
know how to do, namely call a single process and wait for the result. How
can I "map" this call asynchronously and wait until all values are done?
Ideally, I'd like the results in a vector of the same length and order as
the original.
#include <iostream>
#include <thread>
#include <future>
#include <vector>
using namespace std;
double square_add(double x, double y) { return x*x+y; }
int main() {
vector<double> A = {1,2,3,4,5};
// Single evaluation
auto single_result = std::async(square_add,A[2],3);
cout << "Evaluating a single index " << single_result.get() << endl;
// Blocking map
for(auto &x:A) {
auto blocking_result = std::async(square_add,x,3);
cout << "Evaluating a single index " << blocking_result.get() << endl;
}
// Non-blocking map?
return 0;
}
Note: to get this code to compile with gcc I need the -pthreads flag.
I'm trying to learn how to execute "embarrassingly" parallel tasks in
C++11. A common pattern I come across is get the result of a function when
evaluated over a range of values, similar to calling python's
multiprocessing.Pool.map. I've written a minimal example that shows what I
know how to do, namely call a single process and wait for the result. How
can I "map" this call asynchronously and wait until all values are done?
Ideally, I'd like the results in a vector of the same length and order as
the original.
#include <iostream>
#include <thread>
#include <future>
#include <vector>
using namespace std;
double square_add(double x, double y) { return x*x+y; }
int main() {
vector<double> A = {1,2,3,4,5};
// Single evaluation
auto single_result = std::async(square_add,A[2],3);
cout << "Evaluating a single index " << single_result.get() << endl;
// Blocking map
for(auto &x:A) {
auto blocking_result = std::async(square_add,x,3);
cout << "Evaluating a single index " << blocking_result.get() << endl;
}
// Non-blocking map?
return 0;
}
Note: to get this code to compile with gcc I need the -pthreads flag.
What are the Java semantics of an escaped number in a character literal=?iso-8859-1?Q?=2C_e.g._'\15'_=3F_=96_stackoverflow.com?=
What are the Java semantics of an escaped number in a character literal,
e.g. '\15' ? – stackoverflow.com
Please explain what, exactly, happens when the following sections of code
are executed: int a='\15'; System.out.println(a); this prints out 13; int
a='\25'; System.out.println(a); this prints …
e.g. '\15' ? – stackoverflow.com
Please explain what, exactly, happens when the following sections of code
are executed: int a='\15'; System.out.println(a); this prints out 13; int
a='\25'; System.out.println(a); this prints …
Why was my upvoted answer deleted=?iso-8859-1?Q?=3F_=96_meta.stackoverflow.com?=
Why was my upvoted answer deleted? – meta.stackoverflow.com
My answer on Using C# to check if string contains a string in string array
was deleted by a moderator despite having 1 up vote. I would like to
understand why?
My answer on Using C# to check if string contains a string in string array
was deleted by a moderator despite having 1 up vote. I would like to
understand why?
Subscribe to:
Posts (Atom)