I heard, templated member functions of a class can't be virtual. Is it true? BTW, if they can be, then please give an example of such a scenario when I would need such function?
I have some questions about singletons in C++.
Under what situations is a singleton a must?
What are the pros and cons of singletons? I was told they could cause memory leaks, how is that? I was also told that initialization is a problem, is that true?
Hi,
I have program which writes to database which folders are full or empty. Now I'm using
bool hasFiles=false;
(Directory.GetFiles(path).Length 0) ? hasFiles=true: hasFiles=false;
but it takes almost one hour, and I can't do anything in this time.
Is there any fastest way to check if folder has any file ?
I get an "The remote name could not be resolved: 'mine.com'"
When using this open ID identifier:
https://www.google.com/accounts/o8/site-xrds?hd=mine.com
And it's true, that the mine.com DNS record doesn't exist. But I'm wondering why it goes to look there in the first place. All I want to be doing is to check if the user can login to our hosted domain. Is that really so hard?
Is it possible to know that particular dependency already has been satisfied by ninject kernel? To be clear:
Let's suppose we have this module:
Bind<IA>().To<A>();
Bind<IB>().To<B>();
And some "client"-code:
var a = kernel.Get<IA>();
// how to get here "true" for assumption: "IA was requested (once)"
// and "false" for: "IB was not requested ever"
Hello, I'm trying to externalize the QuartzConfig.groovy
I want to be able to set autoStartup to true or false with an external file.
In Config.groovy it is possible to use the grails.config.locations and set properties file that override the properties. Is there something like this in QuartzConfig.groovy ?
Thank you
I am dynamically loading user control in Button Click event, since these user controls are dynamically loaded I have to recreate all previous user controls as well per click. My user control just has two textboxes for now, but I am not able to persist my inputs across postbacks.
My ids are same everytime. I have enableViewstate ="true" in all controls all up to page level. Please adivce.
Using prototype, is there a simple method of checking that a group of values match, for example - can this code be refined to a single line or something otherwise more elegant?
var val = '';
var fail = false;
$('form').select('.class').each(function(e){
if(!val){
val = $F(e);
}else{
if(val != $F(e)) fail = true;
}
});
I am using this code to check the checkbox is chekced or not..
$('#nextpage').click(function() {
var result = $('#Details input[type=checkbox]').attr('checked');
if (result == true) {
$("#tabs").tabs('enable', 3).tabs('select', 3);
}
else {
$().ShowDialog('please select atleast one');
}
});
using this I can check only for one checkbox
if I need to check for multipe checkboxes in teh Details page how do I need to loop throw?
thanks
I have a setting in environment/production.rb of HEROKU = true
This should change my has_attachment has to use s3 instead of the file system, but it doesn't. What's wrong with my logic?
has_attachment :content_type => :image,
:storage => ($HEROKU ? :s3 : :file_system),
...
Thanks!
Time.ToString("0.0") shows up as a decimal "1.5" for instead of 1:30 how can I get it to display in a time format.
private void xTripSeventyMilesRadioButton_CheckedChanged(object sender, EventArgs e)
{
//calculation for the estimated time label
Time = Miles / SeventyMph;
this.xTripEstimateLabel.Visible = true;
this.xTripEstimateLabel.Text = "Driving at this speed the estimated travel time in hours is: " + Time.ToString("0.0") + " hrs";
}
I use opencsv to parse csv files, and my code is
while( (line = reader.readNext()) != null ) { .... }
I got a compiler warning saying:
comparing values of types Unit and Null using `!=' will always yield true
[warn] while( (aLine = reader.readNext()) != null ) {
How should I do the while loop?
Does Ruby (or Rails) provide an easy way to accomplish the following:
if @author.articles.each(:published == true)
puts "all articles of this author are published"
end
I think the example speaks for itself.
How can I find out through reflection what is the string name of the method?
For example given:
class Car{
public void getFoo(){
}
}
I want to get the string "getFoo", something like the following:
Car.getFoo.toString() == "getFoo" // TRUE
Based on the suggestion give here, and the information given here on how to make a custom bindingHandler for a forEach, I decided to attempt to write my own custom binding for a forEach and Masonry.
Because the elements are added on the fly the redrawing and moving around of elements to fill the space doesn't occur. So, this functionality needed to be moved after the elements have been rendered or called after each item has been added.
Here is my bindingHandler
ko.bindingHandlers.masonry = {
init: function (element, valueAccessor, allBindingsAccessor) {
var $element = $(element),
originalContent = $element.html();
$element.data("original-content", originalContent);
//var msnry = new Masonry($element);
return { controlsDescendantBindings: true }
},
update: function (element, valueAccessor, allBindingsAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor()),
//get the list of items
items = value.items(),
//get a jQuery reference to the element
$element = $(element),
//get the current content of the element
elementContent = $element.data("original-content");
$element.html("");
var container = $element[0];
var msnry = new Masonry(container);
for (var index = 0; index < items.length; index++) {
(function () {
//get the list of items
var item = ko.utils.unwrapObservable(items[index]),
$childElement = $(elementContent);
ko.applyBindings(item, $childElement[0]);
//add the child to the parent
$element.append($childElement);
msnry.appended($childElement[0]);
})();
msnry.layout();
msnry.bindResize();
}
}
};
and the HTML implementing the handler.
<div id="criteriaContainer" data-bind="masonry: { items: SearchItems.Items }">
<div class="searchCriterion control-group">
<label class="control-label" data-bind="text: Description"></label>
<div class="controls">
<input type="hidden" data-bind="value: Value, select2: { minimumInputLength: 3, queryUri: SearchUri(), placeholder: Placeholder(), allowClear: true }" style="width: 450px">
</div>
<p data-bind="text: Value"></p>
</div>
</div>
When this shows up on the page It stacks all if the elements rendered via the append method right on top of each other.
You can see in my bindingHandler I am calling bindResize as well as layout(), neither of which seem to be having any effect.
Here's a screenshot of what it looks like in the UI.
how do i have to nest multicheckboxes so that they are named like this 'foo[]['bar']' .
i've used subforms but they give me naming like this 'foo[bar][]'.
my code:
$sub = new Zend_Form_SubForm('sub');
$wish = new Zend_Form_Element_MultiCheckbox('bar');
$wish
->setMultiOptions($education_direction->getAll())
->setLabel('Wish')
->setRequired(true);
$sub-addElements(array(
$wish
));
$this-addSubForm($sub, 'foo');
What's the best algorithm for comparing two arrays to see if they have the same members?
Assume there are no duplicates, the members can be in any order, and that neither is sorted.
compare(
[a, b, c, d],
[b, a, d, c]
) ==> true
compare(
[a, b, e],
[a, b, c]
) ==> false
compare(
[a, b, c],
[a, b]
) ==> false
Hello,
I'm building a shopping cart and I would like to use a JavaScript function to validate user input when entering the quantity value in the quantity text input. I would like to allow the entering of integer values only (no floats, no other characters).
I know that I can apply this function using onKeyUp event and also I found isNaN() function, but it returns true even for floats (which is not ok).
Can you guys help me out with this one?
Thanks.
How would I go about ensuring that the overridden parent method exists before I call it?
I've tried this:
public function func() {
if (function_exists('parent::func')) {
return parent::func();
}
}
However the function_exists never evaluates to true.
Hi,
I was using Sonar to make my code cleaner, and it pointed that I'm using new Integer(1) instead of Integer.valueOf(1). Because it seems that valueOf does not instantiate a new object so is more memory-friendly. How can valueOf not instantiate a new object ? How does it work ? Is this true for all integers ?
thanks.
{"paging": {"pageNum":2,"action":"Next","type":"","availableCacheName":"getAllFunds","selectedCacheName":"","showFrom":101,"showTo":200,"totalRec":289,"pageSize":100},
"Data":[{"sourceCodeId":0,"radio_fund":"individua
l","availableFunds":[],"fundId":288,"searchName":[],"fundName":"Asian Equity Fund A Class Income","srcFundGrpId":"PGI","firstElement":0,"las
tElement":0,"totalElements":0,"pageList":[],"standardExtract":true}]
I have json file with above format with two fileds,one paging and one is Data array.
I able to retrieve values of paging,but i am not able to retrieve the values of data array with .each function of jquery.
Any suggestions or inputs really appreciated.
I've been working far too long with php and getting bored with it. I also want to learn a new language. I've been using Ruby and like it. I've to decide between Rails and Sinatra, which one would you recommend? Is it true that Sinatra can't be used to build complex apps, and its only for simple apps?
Hello,
I have this class constructor:
Pairs (int Pos, char *Pre, char *Post, bool Attach = true);
How can I initialize array of Pairs classes? I tried:
Pairs Holder[3] =
{
{Input.find("as"), "Pre", "Post"},
{Input.find("as"), "Pre", "Post"},
{Input.find("as"), "Pre", "Post"}
};
Apparently it's not working, I also tried to use () brackets instead of {} but compiler keeps moaning all the time. Sorry if it is lame question, I googled quite hard but wasn't able to find answer :/
Thanks.
You used to be abel to do:
resources :posts, :singular => true
But I tried this in rails and it didn't work. Does anyone know the new way or workaround?
thanks
HI,
I am just trying to set a field value and disable it at the same time.
Can this be done in ext js? The docs are very weak on this subject.
something like this generates errors:
myForm.getForm().findField('start_date').setValue('').setDisabled(true);
I'm used to JQuery which does this sort of thing nicely but haven't had luck with Ext.
Thanks for any help.