Could dynamically be got a pointer to a type?
type foo struct {
A uint8
B string
}
func Testing() (*foo) {...}
Using an interface?
func Testing() (*interface{}) {...}
We've got the following repository method
public IList<Foo> GetItems(int fooId, int pageIndex, int pageSize
, string sortField, string sortDir, out int totalItems)
{
// Some code
}
My question is: is it ok to use out in this way. I'm somewhat uncomfortable with out, but can't come up with a better way to write this as a single call.
I have a data file, and a gnu file, in which my plotting commands are.
How can I produce a plot in gnuplot, in a way that I call gnuplot giving it a name of the gnu file ... it gives me the window with a plot ... and after I close it, it returns me not to gnuplot command prompt, but to cmd (windows cmd.exe) command prompt ?
I have a list of tasks. A task is defined by a name, a due date and a duration.
My TaskManager class handles a std::list<Task> sorted by due date. It has to provide a way to get the tasks due for a specific date.
How would you implement that ?
I think a good way (from API point of view) would be to provide a std::list<Task>::iterator pair. So I would have a TaskManager::begin(date) method. Do you think this method should get the iterator by iterating from the start of the list until it finds the first task due on that date, or by getting it from a std::map<date, std::list<Task>::iterator> (but then we have to keep it up-to-date when adding or removing tasks) ?
And then, how could I implement the TaskManager::end(date) method ?
I have a script that has been running for over a year and now it is failing:
It is creating a command file:
open ( FTPFILE, ">get_list");
print FTPFILE "dir *.txt"\n";
print FTPFILE "quit\n";
close FTPFILE;
Then I run the system command:
$command = "ftp ".$Server." < get_list | grep \"\^-\" >new_list";
$code = system($command);
The logic the checks:
if ($code == 0) {
do stuff
} else {
log error
}
It is logging an error. When I print the $code variable, I am getting 256.
I used this command to parse the $? variable:
$exit_value = $? >> 8;
$signal_num = $? & 127;
$dumped_core = $? & 128;
print "Exit: $exit_value Sig: $signal_num Core: $dumped_core\n";
Results:
Exit: 1 Sig: 0 Core: 0
Thanks for any help/insight.
Program stopped compiling at this point:
What is causing this error? (Error is at the bottom of post)
public class JFrameWithPanel extends JFrame implements ActionListener, ItemListener
{
int packageIndex;
double price;
double[] prices = {49.99, 39.99, 34.99, 99.99};
DecimalFormat money = new DecimalFormat("$0.00");
JLabel priceLabel = new JLabel("Total Price: "+price);
JButton button = new JButton("Check Price");
JComboBox packageChoice = new JComboBox();
JPanel pane = new JPanel();
TextField text = new TextField(5);
JButton accept = new JButton("Accept");
JButton decline = new JButton("Decline");
JCheckBox serviceTerms = new JCheckBox("I Agree to the Terms of Service.", false);
JTextArea termsOfService = new JTextArea("This is a text area", 5, 10);
public JFrameWithPanel()
{
super("JFrame with Panel");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pane.add(packageChoice);
setContentPane(pane);
setSize(250,250);
setVisible(true);
packageChoice.addItem("A+ Certification");
packageChoice.addItem("Network+ Certification ");
packageChoice.addItem("Security+ Certifictation");
packageChoice.addItem("CIT Full Test Package");
pane.add(button);
button.addActionListener(this);
pane.add(text);
text.setEditable(false);
text.setBackground(Color.WHITE);
text.addActionListener(this);
pane.add(termsOfService);
termsOfService.setEditable(false);
termsOfService.setBackground(Color.lightGray);
pane.add(serviceTerms);
serviceTerms.addItemListener(this);
pane.add(accept);
accept.addActionListener(this);
pane.add(decline);
decline.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
packageIndex = packageChoice.getSelectedIndex();
price = prices[packageIndex];
text.setText("$"+price);
Object source = e.getSource();
if(source == accept)
{
if(serviceTerms.isSelected() = false) // line 79
{
JOptionPane.showMessageDialog(null,"Please accept the terms of service.");
}
else
{
JOptionPane.showMessageDialog(null,"Thanks.");
}
}
}
Error:
\Desktop\Java Programming\JFrameWithPanel.java:79: unexpected type
required: variable
found : value
if(serviceTerms.isSelected() = false)
^
1 error
JQuery
Assume this works: $('table td').load('/my/url/ div p');
I would end up with <td><p>Some Text</p></td>
I want to end up with <td>Some Text</td>
How would I do that?
I have a controller that takes in a viewmodel and submitbutton
public ActionResult AddLocation(AddLocationViewModel viewModel, string submitButton)
My view is bound to the viewmodel. The viewmodel contains a list objects used to create an html table with checkboxes. Is there a way to access the selected "rows" through the viewmodel in my controller? So that I can iterate through and get the selected items?
Thanks
LDD
Hi,
i have the following code:
<?php
$pictureurl="http://icons3.iconfinder.netdna-cdn.com/data/icons/pool/poolbird.png";
if(filter_var($pictureurl, FILTER_VALIDATE_URL) === FALSE){
echo "Invalid Url";
exit;
}else{
echo "Works!";
}
?>
This display "invalid url" for the above url, but not for other simpler urls. Is this a bug? you can even access the image.
And the most important is what's the solution for this?
Thanks
Say, i have a function which returns a reference and i want to make sure that the caller only gets it as a reference and should not receive it as a copy.
Is this possible in C++?
Thanks,
Gokul.
i'm loading photos from my library just fine, but photos coming from he camera don't display in the imageView. I've used CFShow(info) and the data from the camera is not nil...
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
[self.imageView setImage:image];
[self dismissModalViewControllerAnimated:YES];
[picker release];
}
my list has value such as
m=[['na','1','2']['ka','31','45']['ra','3','5']
d=0
r=2
t=m[d][r]
print t # this is givin number i.e 2
Now when I use this value
u=[]
u=m[t]
I am getting an err msg saying type error list does take str values...
i want to use like this how can i convert that t into a integer??
please suggest..
thanks..
I want to write a function which takes a list and constructs a subset of that list of a certain length based on the output of a function.
If I were simply interested in the first 50 elements of the sorted list xs, then I would use fst (splitAt 50 (sort xs)).
However, the problem is that elements in my list rely on other elements in the same list. If I choose element p, then I MUST also choose elements q and r, even if they are not in the first 50 elements of my list. I am using a function finderFunc which takes an element a from the list xs and returns a list with the element a and all of its required elements. finderFunc works fine. Now, the challenge is to write a function which builds a list whose total length is 50 based on multiple outputs of finderFunc.
Here is my attempt at this:
finish :: [a] -> [a] -> [a]
--This is the base case, which adds nothing to the final list
finish [] fs = []
--The function is recursive, so the fs variable is necessary so that finish
-- can forward the incomplete list to itself.
finish ps fs
-- If the final list fs is too small, add elements to it
| length fs < 50 && length (fs ++ newrs) <= 50 = fs ++ finish newps newrs
-- If the length is met, then add nothing to the list and quit
| length fs >= 50 = finish [] fs
-- These guard statements are currently lacking, not the main problem
| otherwise = finish [] fs
where
--Sort the candidate list
sortedps = sort ps
--(finderFunc a) returns a list of type [a] containing a and all the
-- elements which are required to go with it. This is the interesting
-- bit. rs is also a subset of the candidate list ps.
rs = finderFunc (head sortedps)
--Remove those elements which are already in the final list, because
-- there can be overlap
newrs = filter (`notElem` fs) rs
--Remove the elements we will add to the list from the new list
-- of candidates
newps = filter (`notElem` rs) ps
I realize that the above if statements will, in some cases, not give me a list of exactly 50 elements. This is not the main problem, right now. The problem is that my function finish does not work at all as I would expect it to. Not only does it produce duplicate elements in the output list, but it sometimes goes far above the total number of elements I want to have in the list.
The way this is written, I usually call it with an empty list, such as: finish xs [], so that the list it builds on starts as an empty list.
I have a table "abc" where i store timestamp having multiple records let suppose
1334034000 Date:10-April-2012
1334126289 Date:11-April-2012
1334291399 Date:13-April-2012
I want to build a sql query where I can find at first attempt the records having last two day values and so second time the next two days . . .
Example:
Select *,dayofmonth(FROM_UNIXTIME(i_created)) from notes
where dayofmonth(FROM_UNIXTIME(i_created)) > dayofmonth(FROM_UNIXTIME(i_created)) -2
order by dayofmonth(FROM_UNIXTIME(i_created))
this query returns all the records date wise but we need very most two days record.
Please suggest accordingly.
Thanks in advance
I have a user defined function called Sync_CheckData under Scalar-valued functions in Microsoft SQL Server. What it actually does is to check the quantity of issued product and balance quantity are the same. If something is wrong, returns an ErrorStr nvarchar(255).
Output Example:
Balance Stock Error for Product ID : 4
From the above string, I want to get 4 so that later on I can SELECT the rows which is giving errors by using WHERE clause (WHERE Product_ID = 4).
Which SQL function can I use to get the substring?
In my app I simply open the list of activities and when a contact is clicked I attempt to retrieve the name of the contact selected and put it into a string. The app crashes in the onActivityResult() function. I do have the READ_CONTACTS permission set.
/**
* Opens the contacts activity
*/
public void openContacts() {
Intent intent = new Intent(Intent.ACTION_PICK, People.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
}
@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
super.onActivityResult(reqCode, resultCode, data);
switch (reqCode) {
case (PICK_CONTACT) :
if (resultCode == Activity.RESULT_OK) {
Uri contactData = data.getData();
Cursor c = managedQuery(contactData, null, null, null, null); //NullPointerException thrown here, line 102
if (c.moveToFirst()) {
String name = c.getString(c.getColumnIndexOrThrow(People.NAME));
FRIEND_NAME = name;
showConfirmDialog(name);
}
}
break;
}
}
The following logcat error logs are returned:
Any help is appreciated.
Thanks
I would like to know how to get data from multiple tables in my database, what types of methods are there to do this, what are joins and unions and how are they different from one another? When should I use each one compared to the others?
I am planning to use this in my (for example - PHP) application, but don't want to run multiple queries against the database, what options do I have to get data from multiple tables in a single query?
Note: I am writing this as I would like to be able to link to a well written guide on the numerous questions that I constantly come across in the PHP queue, so I can link to this for further detail when I post an answer.
The answers cover off the following:
Part 1 - Joins and Unions
Part 2 - Subqueries
Part 3 - Tricks and Efficient Code
In a JQuery autocomplete which uses an array of objects as its source, can I display the label in the INPUT and later access the value? The default behavior is that the value is displayed in the INPUT after selection. In this case the values represent indexes to unique keys in rows in a table.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>autocomplete demo</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
</head>
<body>
<label for="autocomplete">Select a programming language: </label>
<input id="autocomplete">
<script>
$( "#autocomplete" ).autocomplete({
source: [ { label:"c++", value:1 }, { label: "java", value:2 }, { label: "javascript", value:3 } ]
});
</script>
</body>
</html>
So I have the following code contained within an HttpModule in an application I've been asked to support:
app.Context.Response.ContentType = "text/xml";
app.Context.Items.Add("IpixRoomId", ipixRoomId);
app.Context.Items.Add("IpixId", ipixId);
app.Context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
app.Context.RewritePath(rewriteUrl, true);
What's the purpose of adding data to Context.Items when the content type is XML?
EDIT: For clarification, I'm calling up this URL:
http://website.com/virtualtour/1971/6284/panorama2flash.swf
I assume the SWF file (I know very little about Flash) makes another call to http://website.com/virtualtour/config.xml. The code I pasted above only executes on calls to config.xml. So since it's only the SWF file and config.xml being requested from the server, I'm a little confused. Can the .SWF file have access to HttpContext.Current.Items?
Other than the HttpModule, there is no .NET involved in the code, it's a straight request to the SWF file which triggers a call to config.xml but it seems that those Context.Items contain the data needed to make the SWF file display the right virtual tour. I'm just missing where that link happens. It can't happen in the XML, so maybe in Flash?
Hello, I'm very new to multithreading and lack experience. I need to compute some data in a different thread so the UI doesn't hang up, and then send the data as it is processed to a table on the main form. So, basically, the user can work with the data that is already computed, while other data is still being processed. What is the best way to achieve this? I would also be very grateful for any examples. Thanks in advance.
silly php question...
why cant i do this?
echo Auth::getFullUser()[ 'country' ];
instead you have to do this
$user = Auth::getFullUser();
echo $user[ 'country' ];
Under
(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)
peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier{}
is it possible to get returned the phone number or somewhat the user has clicked?
i'm trying to get a list of the most recent used applications. NSWorkspace returns me a list of active applications and i can sort them on a few options using NSRunningApplication. see list below:
launchDate
finishedLaunching
processIdentifier
i dont want the lauch date but the recent 'active' date (like the way cmd-tab sorts).
Does anyone knows the solution for this?
This line:
used_emails = [row.email for row
in db.execute(select([halo4.c.email], halo4.c.email!=''))]
Returns:
['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']
I use this to find a match:
if recipient in used_emails:
If it finds a match I need to pull another field (halo4.c.code) from the database in the same row. Any suggestions on how to do this?