how to use foreach loop for clear the all textboxes?
public void clear()
{
lblage.Text = "";
lblclosingbirds.Text = "";
lbltypeoffeed.Text = "";
lbltypeoffeedf.Text = "";
lblstdfeed.Text = "";
lblstdfeedf.Text = "";
lblstdhd.Text = "";
lblstdhe.Text = "";
lblExpeggs.Text = "";
lblbirdsf.Text = "";
txtacteggs.Text = "";
txtactfeed.Text = "";
txtactfeedf.Text = "";
txtfemaleclosingstock50.Text = "";
txtfemaleclosingstock70.Text = "";
txtmale50kgcstock.Text = "";
txtmale70kgscstock.Text = "";
txtmort.Text = "";
txtmortf.Text = "";
txtuseeggs.Text = "";
ddlFemaleFeedtype.SelectedValue = "0";
ddlMaleFeedtype.SelectedValue = "0";
}
how to use foreach loop method for replace with clear()..please tell me..
any one... is it possible to write foreach loop...please tell me
Thursday, 3 October 2013
Wednesday, 2 October 2013
Batch script to remove parts of a filename
Batch script to remove parts of a filename
Help please!
I need to remove time stamp and file number off of the filename using a
windows batch script. Thank you! Thank you in advance!
OLD Filename= CAM168-NOTSET.2013.10.01.18.45.45.882.jpg
NEW Filename= CAM168-NOTSET.jpg
Help please!
I need to remove time stamp and file number off of the filename using a
windows batch script. Thank you! Thank you in advance!
OLD Filename= CAM168-NOTSET.2013.10.01.18.45.45.882.jpg
NEW Filename= CAM168-NOTSET.jpg
Connecting phonegap with Facebook
Connecting phonegap with Facebook
Please, any help/solutions for this: connecting and merging Facebook with
our phonegap application (version 3.0.9) so we may post on Facebook - from
the phonegap applicaton's behalf using the post dialog.
Basically, when an action is done on the application, it would post to
Facebook (such as when someone is listening to a song on Spotify and it
says on FB, or when someone likes something on Instagram and it posts on
FB, etc).
We are using phonegap version 3.0.9.
Please, any help/solutions for this: connecting and merging Facebook with
our phonegap application (version 3.0.9) so we may post on Facebook - from
the phonegap applicaton's behalf using the post dialog.
Basically, when an action is done on the application, it would post to
Facebook (such as when someone is listening to a song on Spotify and it
says on FB, or when someone likes something on Instagram and it posts on
FB, etc).
We are using phonegap version 3.0.9.
JSF 2.0 & PrimeFaces cannot be resolved as a member of
JSF 2.0 & PrimeFaces cannot be resolved as a member of
I have a bean:
package controller.types;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class Test
{
static List<MainTableRow> rows;
public Test()
{
rows = new ArrayList<>();
}
public static List<MainTableRow> getRows()
{
return rows;
}
public static void setRows(List<MainTableRow> rows)
{
Test.rows = rows;
}
}
And my xhtml page is:
<h:form>
<p:fileUpload
fileUploadListener="#{fileUploadController.handleFileUpload}"
mode="advanced" dragDropSupport="false" update="messages"
sizeLimit="10000000" fileLimit="3"
allowTypes="/(\.|\/)(xls)$/" style="font-size: 14px"/>
<p:growl id="messages" showDetail="true" />
<p:dataTable id="dataTable" var="mainTableRow"
value="#{test.rows}" style="font-size: 14px">
<f:facet name="header">
Main Table
</f:facet>
<p:column sortBy="" headerText="Index">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="Query">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="S1">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="S2">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="S3">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="S9">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="Uygunluk">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="Kural">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="Kaynak">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="Query Type">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="User Intent">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
</p:dataTable>
</h:form>
At line <p:dataTable id="dataTable" var="mainTableRow"
value="#{test.rows}" style="font-size: 14px"> it gives error:
rows cannot be resolved as a member of test
What is the reason?
I have a bean:
package controller.types;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class Test
{
static List<MainTableRow> rows;
public Test()
{
rows = new ArrayList<>();
}
public static List<MainTableRow> getRows()
{
return rows;
}
public static void setRows(List<MainTableRow> rows)
{
Test.rows = rows;
}
}
And my xhtml page is:
<h:form>
<p:fileUpload
fileUploadListener="#{fileUploadController.handleFileUpload}"
mode="advanced" dragDropSupport="false" update="messages"
sizeLimit="10000000" fileLimit="3"
allowTypes="/(\.|\/)(xls)$/" style="font-size: 14px"/>
<p:growl id="messages" showDetail="true" />
<p:dataTable id="dataTable" var="mainTableRow"
value="#{test.rows}" style="font-size: 14px">
<f:facet name="header">
Main Table
</f:facet>
<p:column sortBy="" headerText="Index">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="Query">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="S1">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="S2">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="S3">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="S9">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="Uygunluk">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="Kural">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="Kaynak">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="Query Type">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
<p:column sortBy="" headerText="User Intent">
<h:outputText value="#{mainTableRow.index}" />
</p:column>
</p:dataTable>
</h:form>
At line <p:dataTable id="dataTable" var="mainTableRow"
value="#{test.rows}" style="font-size: 14px"> it gives error:
rows cannot be resolved as a member of test
What is the reason?
Best/your practices in Python for sharing global variables, shared functions and classes
Best/your practices in Python for sharing global variables, shared
functions and classes
Thanks for looking at this, I've been mulling over this for hours to no
avail. Essentially, I want to make my code more modular and share-able:
you can see how the following files made up a much larger one initially.
It's not working and I suspect it's because I'm trying to do things in
Python that I'm not supposed to:
app_config.py
app_name = "quick scraper"
mysql_db = ... # intended "global" variable that connects to database
main.py
from app_config import * # Getting shared variables
import app_library # See code app_library.py below
...
logger = logging.getLogger(app_name) # logger object to be shared later
...
app_library.dlAndSaveWebpage(url) # Module has key helper functions
...
app_library.py
import app_models_orm as app_models
def dlAndSaveWebpage(url)
# download and process url
...
app_models.Webpage(url=url, body=body)
app_models_orm.py
class MySQLModel(Model):
class Meta:
database = mysql_db
class Webpage(MySQLModel):
id = ...
...
Class MySQLModel of app_models_orm.py fails because variable mysql_db does
not exist in the file. I could do an import app_config, but I want to have
app_models_orm.py be used by multiple scripts within the same directory.
If I have to do an import of a file custom to a script, then I'd have to
make copies of the models file, which just seems bizarre and wrong.
Similarly, I want to use app_library.py by multiple scripts in the same
directory. It seems to make sense to call app_library from main.py, but if
app_library needs to reference variables directly from app_config.py, I'd
have to also make copies of app_library.py.
main.py contains a logger object that, when all of this code was put
together in one file, all the various methods could access/use. How can
(or should?) app_library.py functions access this instance of the logger
class?
Again, thanks for the help. Feel free to "teach me how to catch fish" in
this instance too: I saw many posts about using a global import file, but
that doesn't help the intention to share the latter two files without
adding in custom imports, nor does it help with the models file which,
when imported, hits an error because the class is seeking a variable that
isn't in the file. There's probably a right way to do all this, and I
imagine many of you would know how.
functions and classes
Thanks for looking at this, I've been mulling over this for hours to no
avail. Essentially, I want to make my code more modular and share-able:
you can see how the following files made up a much larger one initially.
It's not working and I suspect it's because I'm trying to do things in
Python that I'm not supposed to:
app_config.py
app_name = "quick scraper"
mysql_db = ... # intended "global" variable that connects to database
main.py
from app_config import * # Getting shared variables
import app_library # See code app_library.py below
...
logger = logging.getLogger(app_name) # logger object to be shared later
...
app_library.dlAndSaveWebpage(url) # Module has key helper functions
...
app_library.py
import app_models_orm as app_models
def dlAndSaveWebpage(url)
# download and process url
...
app_models.Webpage(url=url, body=body)
app_models_orm.py
class MySQLModel(Model):
class Meta:
database = mysql_db
class Webpage(MySQLModel):
id = ...
...
Class MySQLModel of app_models_orm.py fails because variable mysql_db does
not exist in the file. I could do an import app_config, but I want to have
app_models_orm.py be used by multiple scripts within the same directory.
If I have to do an import of a file custom to a script, then I'd have to
make copies of the models file, which just seems bizarre and wrong.
Similarly, I want to use app_library.py by multiple scripts in the same
directory. It seems to make sense to call app_library from main.py, but if
app_library needs to reference variables directly from app_config.py, I'd
have to also make copies of app_library.py.
main.py contains a logger object that, when all of this code was put
together in one file, all the various methods could access/use. How can
(or should?) app_library.py functions access this instance of the logger
class?
Again, thanks for the help. Feel free to "teach me how to catch fish" in
this instance too: I saw many posts about using a global import file, but
that doesn't help the intention to share the latter two files without
adding in custom imports, nor does it help with the models file which,
when imported, hits an error because the class is seeking a variable that
isn't in the file. There's probably a right way to do all this, and I
imagine many of you would know how.
Tuesday, 1 October 2013
CURSOR OR UNION ALL - UNION ALL IS SLOW
CURSOR OR UNION ALL - UNION ALL IS SLOW
Have a query that I run on the first of the month that goes against 6
databases.. Problem is that when run, it takes upward of 3 hours to run.
Thinking about this, I could do this with either a UNION ALL with PIVOT -
which is what is used today.. Or I could do a CURSOR from master do loop
through the databases on the server. But, I have to ask myself, how
efficient is this query?
SELECT *
FROM (
SELECT
'db1' AS DB
,YEAR(dateadd(hh,-5,ETIME)) as [YEAR]
,LEFT(DATENAME(MONTH, dateadd(hh,-5,ETIME)), 3) AS MONTH
,CASE WHEN ID IS NULL THEN 'NoTYPE' ELSE 'TYPE' END AS 'TYPE'
,ACT
,COUNT(ACT) AS Amount
FROM DB1.dbo.LOG (nolock) JOIN
DB1.dbo.TABL (nolock) ON DB1.dbo.LOG.ID = DB1.dbo.TABL.NAME COLLATE
SQL_Latin1_General_CP1_CI_AS
--WHERE dateadd(hh,-5,ETIME) >
dateadd(MM,-3,dateadd(day,datediff(day,0,getdate()),0))
GROUP BY YEAR(dateadd(hh,-5,ETIME))
, LEFT(DATENAME(MONTH, dateadd(hh,-5,ETIME)), 3)
, CASE WHEN ID IS NULL THEN 'NoTYPE' ELSE 'TYPE' END
, DB1.dbo.LOG.ACT
UNION ALL
-- next db.. AND 4 FOUR MORE..
) as s
PIVOT
(
SUM(Amount)
FOR [month] IN (JAN, FEB, MAR, APR,
MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC)
)
as PVT
Then we are doing the same thing by quarter..
SELECT *
FROM (
SELECT
'db1' AS DB
, YEAR(DATEADD(hh, - 5, DB1.dbo.LOG.ETIME)) AS YEAR
, DATEPART(q, DB1.dbo.LOG.ETIME) AS QUARTER
,CASE WHEN ID IS NULL THEN 'NoTYPE' ELSE 'TYPE' END AS 'TYPE'
,ACT
,COUNT(ACT) AS Amount
FROM DB1.dbo.LOG (nolock) JOIN
DB1.dbo.TABL (nolock) ON DB1.dbo.LOG.ID = DB1.dbo.TABL.NAME COLLATE
SQL_Latin1_General_CP1_CI_AS
GROUP BY YEAR(DB1.dbo.LOG.ETIME)
, DATEPART(q, DB1.dbo.LOG.ETIME)
, DB1.dbo.LOG.ACT
, YEAR(DATEADD(hh, - 5, DB1.dbo.ETIME))
UNION ALL
-- next db.. AND 4 FOUR MORE..
) as s
PIVOT
(
sum(Amount)
FOR [quarter] IN ([1], [2], [3], [4])
)
as PVT
Thanks,
Kent
Have a query that I run on the first of the month that goes against 6
databases.. Problem is that when run, it takes upward of 3 hours to run.
Thinking about this, I could do this with either a UNION ALL with PIVOT -
which is what is used today.. Or I could do a CURSOR from master do loop
through the databases on the server. But, I have to ask myself, how
efficient is this query?
SELECT *
FROM (
SELECT
'db1' AS DB
,YEAR(dateadd(hh,-5,ETIME)) as [YEAR]
,LEFT(DATENAME(MONTH, dateadd(hh,-5,ETIME)), 3) AS MONTH
,CASE WHEN ID IS NULL THEN 'NoTYPE' ELSE 'TYPE' END AS 'TYPE'
,ACT
,COUNT(ACT) AS Amount
FROM DB1.dbo.LOG (nolock) JOIN
DB1.dbo.TABL (nolock) ON DB1.dbo.LOG.ID = DB1.dbo.TABL.NAME COLLATE
SQL_Latin1_General_CP1_CI_AS
--WHERE dateadd(hh,-5,ETIME) >
dateadd(MM,-3,dateadd(day,datediff(day,0,getdate()),0))
GROUP BY YEAR(dateadd(hh,-5,ETIME))
, LEFT(DATENAME(MONTH, dateadd(hh,-5,ETIME)), 3)
, CASE WHEN ID IS NULL THEN 'NoTYPE' ELSE 'TYPE' END
, DB1.dbo.LOG.ACT
UNION ALL
-- next db.. AND 4 FOUR MORE..
) as s
PIVOT
(
SUM(Amount)
FOR [month] IN (JAN, FEB, MAR, APR,
MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC)
)
as PVT
Then we are doing the same thing by quarter..
SELECT *
FROM (
SELECT
'db1' AS DB
, YEAR(DATEADD(hh, - 5, DB1.dbo.LOG.ETIME)) AS YEAR
, DATEPART(q, DB1.dbo.LOG.ETIME) AS QUARTER
,CASE WHEN ID IS NULL THEN 'NoTYPE' ELSE 'TYPE' END AS 'TYPE'
,ACT
,COUNT(ACT) AS Amount
FROM DB1.dbo.LOG (nolock) JOIN
DB1.dbo.TABL (nolock) ON DB1.dbo.LOG.ID = DB1.dbo.TABL.NAME COLLATE
SQL_Latin1_General_CP1_CI_AS
GROUP BY YEAR(DB1.dbo.LOG.ETIME)
, DATEPART(q, DB1.dbo.LOG.ETIME)
, DB1.dbo.LOG.ACT
, YEAR(DATEADD(hh, - 5, DB1.dbo.ETIME))
UNION ALL
-- next db.. AND 4 FOUR MORE..
) as s
PIVOT
(
sum(Amount)
FOR [quarter] IN ([1], [2], [3], [4])
)
as PVT
Thanks,
Kent
Inheritance Using Button
Inheritance Using Button
I have an assignment where I have to JPanels and I need to be able to push
button1 in jpanel1 and get information to change on button2 of jpanel2.
I've been working on the problem for a few days and no matter what I try I
get stuck.
My idea is that I need a method to convert the button in jpanel2 to a
button in jpanel that changes once the button in jpanel1 is pushed. Thing
is that I can't figure out how to get a method to work with a button.
Here's what I have so far.
MyJPanel:
public class myJPanel extends JPanel {
public myJPanel()
{
super();
JButton j2 = new JButton("..");
setBackground(Color.gray);
setLayout(new BorderLayout());
myJPanel1 p1 = new myJPanel1(JButton(j2)); // thought something
//like this would work to pass jpanel2 to jpanel1 using
//myjpanel as the common class
add(p1,"North");
myJPanel2 p2 = new myJPanel2(j2);
add(p2,"Center");
}
panel1
public class myJPanel1 extends JPanel implements ActionListener
{
student st1 = new student("Fred","Fonseca",44);
JButton j = new JButton(st1.getInfo());
JButton b1 = new JButton("..");
public myJPanel1(JButton j2)
{
super();
setBackground(Color.yellow);
// the whatsUp of this student has to shown in the other panel
j.addActionListener(this);
add(j);
add(b1);
}
public void actionPerformed(ActionEvent event)
{
Object obj = event.getSource();
//=====================================
if (obj == j){
{j2.setText(st1.whatsUp()); // Output on JButton in JPanel2
{b1.setText(st1.whatsUp());
}
}
}
}
}
jpanel2
public class myJPanel2 extends JPanel { JButton j1 = new JButton("When the
user clicks on the button in the UPPER panel" );
public void setButton(JButton j2){
j1 = j2; // shouldn't this pass convert the information
//between the classes?
}
public myJPanel2(JButton j1)
{
super();
setBackground(Color.pink);
setLayout(new GridLayout(3,1));
add(j1);
j1.setText("");
}
}
I have an assignment where I have to JPanels and I need to be able to push
button1 in jpanel1 and get information to change on button2 of jpanel2.
I've been working on the problem for a few days and no matter what I try I
get stuck.
My idea is that I need a method to convert the button in jpanel2 to a
button in jpanel that changes once the button in jpanel1 is pushed. Thing
is that I can't figure out how to get a method to work with a button.
Here's what I have so far.
MyJPanel:
public class myJPanel extends JPanel {
public myJPanel()
{
super();
JButton j2 = new JButton("..");
setBackground(Color.gray);
setLayout(new BorderLayout());
myJPanel1 p1 = new myJPanel1(JButton(j2)); // thought something
//like this would work to pass jpanel2 to jpanel1 using
//myjpanel as the common class
add(p1,"North");
myJPanel2 p2 = new myJPanel2(j2);
add(p2,"Center");
}
panel1
public class myJPanel1 extends JPanel implements ActionListener
{
student st1 = new student("Fred","Fonseca",44);
JButton j = new JButton(st1.getInfo());
JButton b1 = new JButton("..");
public myJPanel1(JButton j2)
{
super();
setBackground(Color.yellow);
// the whatsUp of this student has to shown in the other panel
j.addActionListener(this);
add(j);
add(b1);
}
public void actionPerformed(ActionEvent event)
{
Object obj = event.getSource();
//=====================================
if (obj == j){
{j2.setText(st1.whatsUp()); // Output on JButton in JPanel2
{b1.setText(st1.whatsUp());
}
}
}
}
}
jpanel2
public class myJPanel2 extends JPanel { JButton j1 = new JButton("When the
user clicks on the button in the UPPER panel" );
public void setButton(JButton j2){
j1 = j2; // shouldn't this pass convert the information
//between the classes?
}
public myJPanel2(JButton j1)
{
super();
setBackground(Color.pink);
setLayout(new GridLayout(3,1));
add(j1);
j1.setText("");
}
}
C++14 std::dynarray vs std::vector stackoverflow.com
C++14 std::dynarray vs std::vector – stackoverflow.com
C++14 presents std::dynarray: std::dynarray is a sequence container that
encapsulates arrays with a size that is fixed at construction and does not
change throughout the lifetime of the ...
C++14 presents std::dynarray: std::dynarray is a sequence container that
encapsulates arrays with a size that is fixed at construction and does not
change throughout the lifetime of the ...
Any way to massively edit broken github twitter bootstrap links=?iso-8859-1?Q?=3F_=96_meta.stackoverflow.com?=
Any way to massively edit broken github twitter bootstrap links? –
meta.stackoverflow.com
Twitter Bootstrap was moved from the Twitter organization to the TWBS
organization. This has resulted in numerous broken links all over the
internet and it would be nice if GitHub did something about …
meta.stackoverflow.com
Twitter Bootstrap was moved from the Twitter organization to the TWBS
organization. This has resulted in numerous broken links all over the
internet and it would be nice if GitHub did something about …
Subscribe to:
Comments (Atom)