You used to be abel to do:
resources :posts, :singular => trueBut I tried this in rails and it didn't work. Does anyone know the new way or workaround?
thanks
Under what circumstances will the "False" part of the following code be executed?
x = 20;
y = -30;
if (x > y) {
// True part
}
else {
// False part
}
NB: Language is C, compiler is gcc (although some other compilers may also do the same thing).
This is my method to handle XMLHTTPRequests.
Avoids mysql request, foreign access, nerves user, double requests.
jquery
var allow=true;
var is_loaded="";
$(document).ready(function(){
....
$(".xx").on("click",functio(){
if(allow){
allow=false;
if(is_loaded!="that"){
$.post("job.php", {job:"that",word:"aaa",number:"123"},function(data){
$(".aaa").html(data);
is_loaded="that";
});
}
setTimeout(function(){allow=true},500);
}
....
});
job.php
<?PHP
ob_start('ob_gzhandler');
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) or strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')exit("bad boy!");
if($_POST['job']=="that"){
include "includes/that.inc;
}
elseif($_POST['job']==
....
ob_end_flush();
?>
that.inc
if(!preg_match("/\w/",$_POST['word'])exit("bad boy!");
if(!is_numeric($_POST['number'])exit("bad boy!");
//exclude more.
$path="temp/that_".$row['word']."txt";
if(file_exists($path) and filemtime("includes/that.inc")<$filemtime($path)){
readfile($path);
}
else{
include "includes/openSql.inc";
$call=sql_query("SELECT * FROM that WHERE name='".mysql_real_escape_string($_POST['word'])."'");
if(!$call)exit("ups");
$out="";
while($row=mysql_fetch_assoc($call)){
$out.=$_POST['word']." loves the color ".$row['color'].".<br/>";
}
echo $out;
$fn=fopen($path,"wb");
fputs($fn,$out);
fclose($fn);
}
if something change at the database, you just have to delete involved files.
Hope it was English.
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.
friends,
i want to set android:layout_centerVertical="true" property of layout
through java code of an image.
can any one guide me how to achieve this. here is my code.
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
params.height = (int)totalHeight;
img.setLayoutParams(params);
i have tried using setScaleType(ScaleType.FIT_CENTER) but no use.
any help would be appriciated.
Is it possible to render different actions based on what fails at validation?
For example - I have one field in the form - email addres. It is validated like this:
validates :email,
:presence => true,
:uniqueness => { :case_sensitive => false }
In the controller:
def create
@user = User.new(params[:user])
if @user.save
redirect_to somewhere
else
# render :new if email is blank
# redirect_to somwhere if email is taken
end
end
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?
If System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(Server.MapPath("images/TravelogueGallery/" & getMaxID()))) Then
System.IO.Directory.Delete(HttpContext.Current.Server.MapPath("images/TravelogueGallery/" & getMaxID()), True)
End If
I am using the above code snippet to delete a directory but i get this error "'G:\Projects\Latest\LTCIndia 05-04-12 1415\images\TravelogueGallery\19' is not a valid virtual path. "
Whats wrong with the code?
How does PHP read if statements?
I have the following if statements in this order
if ( $number_of_figures_in_email < 6) {
-- cut: gives false
}
if($number_of_emails > 0) {
-- cut: gives false
}
if ( $number_of_emails == 0) {
-- cut: gives true
}
The code behaves randomly. It sometimes goes to the third if clause and gives me a success, while sometimes to the one of the first two if clauses when the input variables are constant.
This suggests me that I cannot code only with if statements.
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
I came upon a comment on another forum today and one user responding to another suggested that a CS degree is really only good for one through two years at the most, and after that its as if you never had it. Is this really true? is this what employers think?
When I did CS I never learned anything new, we learned fundamentals like data structures, algorithms, time complexity, OS fundamentals, language characteristics. Most of this stuff has been around for the past 20 years or so.
I have put several buttons and panels in my update panel. I also have a script manager on that page. now when I click on any of the buttons then the functionality is working fine but problem is that the complete page gets reloaded witha a flick, instead of updating the update panel only.
I have set the "children as trigger" property of update panel "true".
please help.
I have setAttribute(Qt::WA_OpaquePaintEvent,true) on a widget. From a mouseMoveEvent, I scroll the widget. Now what I need to do is to update the newly exposed area, but it seems that doing this from the paintevent function create an artifact because there is a delay created when the user keeps scrolling. In other words, the widget seems to have scrolled again between the call to scrool and the call or end of paintevent.
For example, while the paint event is trying to draw the desired area, the widget is still scrolling
I have this error:
'people' is an invalid keyword argument for this function
class Passage(models.Model):
name= models.CharField(max_length = 255)
who = models.ForeignKey(UserProfil)
class UserPassage(models.Model):
passage = models.ForeignKey(Passage)
people = models.ManyToManyField(UserProfil, null=True)
class UserProfil(models.Model):
user = models.OneToOneField(User)
name = models.CharField(max_length=50)
I try:
def join(request):
user = request.user
user_profil = UserProfil.objects.get(user=user)
passage = Passage.objects.get(id=2)
#line with error
up = UserPassage.objects.create(people= user_profil, passage=passage)
return render_to_response('thanks.html')
How to do correctly?
Thanks!
After writing all the comments inside the code about the javadoc such as
/**
* This method compares the student's answer to the standard answer * @param ans The student's answer
* @return True for correct answer; False for incorrect answer
*/
boolean compareAnswer(int ans);
I guess it starts with :
javadoc [optionss] [packages|files]
I'm not sure what is the regular or default [option] and how can I say to produce it in my current home directory?
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
This seems to work on everything but explorer:
NextButJar.addEvent("click", function() {
if (this.disabled == true) {
alert("Please view all tabs first!");
return;
}
});
Any help welcome
$this->totplpremium is 2400
$this->minpremiumq is 800
So why would this ever return true?!
if ($this->totplpremium < $this->minpremiumq){
The figures are definitely correct and I am definitely using the 'less than' symbol. I can't work it out.
how do i set a sql server connection to readonly? i tried googling and all i found was File Mode=Read Only but it didnt work (File Mode keyword not supported). And the reference looked sql ce specific.
No luck with sqlite Read Only=True either.
I have a asp:GridView with a HyperLinkField. It's DataNavigateUrlFormatString property is set to View.aspx?id={0}&isTechnical={1}
Select command of appropriate SqlDataSource returns columns of type INT and BIT (from SQL Server 2008).
So displayed string becomes something like View.aspx?id=1&isTechnical=1. But I want to display isTechnical=true|False, i.e. Convert.ToBoolean(row["isTechnical"]).ToString().ToLowerInvariant().
How to implement such conversion in page markup?
I have a column defined like this:
<DataGridTextColumn Binding="{Binding Path=FileSizeBytes, Mode=OneWay}" Header="Size" IsReadOnly="True" />
But instead of displaying the file size as a big number, I'd like to display units, but still have it sort by the actual FileSizeBytes. Is there some way I can run it through a function or something before displaying it?
Objects with the same set of attributes and methods belongs to the same class?
Can't I declare two identical classes with the same methods and attributes, instanciate them and have "objects with the same set of attributes and methods that belongs to different class"?
This question is not about good practices... It's about the logical value (true or false) of the question on the title.
{"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 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?